CharlesShang / FastMaskRCNN

Mask RCNN in TensorFlow
Apache License 2.0
3.1k stars 1.1k forks source link

how to test data ?? #135

Open iFighting opened 7 years ago

iFighting commented 7 years ago

how to test data ??

simaoh commented 7 years ago

I can load the model from this Checkpoint (https://github.com/CharlesShang/FastMaskRCNN/issues/86#issuecomment-309022377), and get predictions from it. However, I can only get predictions for an output_tensor before the ROIAlign layer, but not for any tensor in the graph after that layer. Example:

# this works
output_tensor = graph.get_tensor_by_name("pyramid_1/ROIAlign_2/Crop:0")
# this doesn't work
output_tensor = graph.get_tensor_by_name("pyramid_1/ROIAlign_2/Reshape_2:0")

There's a bug in the ROIAlign layer with the py_func used to generate anchors.

tf.reset_default_graph()
checkpoint_dir = "/my/directory/for/segmentation/FastMaskRCNN/output/mask_rcnn/500k/"
meta_file_path = checkpoint_dir + "coco_resnet50_model.ckpt-499999.meta"
ckpt_file_path = checkpoint_dir + "coco_resnet50_model.ckpt-499999"

# load graph
saver = tf.train.import_meta_graph(meta_file_path, clear_devices=True)
graph = tf.get_default_graph()

# initialize and load weights
sess =  tf.Session()
sess.run(tf.global_variables_initializer())
saver.restore(sess, ckpt_file_path)

# Input images
input_tensor = graph.get_tensor_by_name("Reshape_2:0")
output_tensor = graph.get_tensor_by_name("pyramid_2/MaskEncoder/Reshape_2:0")

# Mask output 
results = sess.run(
    [output_tensor],
    #[tf.reduce_mean(input_tensor)],
    feed_dict={input_tensor:images}
)
y-dep commented 7 years ago

@simaoh Hi,simaoh , have you fixed it? are you able to test your own image now?