Open angyee opened 5 years ago
mask
value is a list of boolean numpy arrays, in order to convert it to an image and display you can use:
mask_val = result['mask'][0]
mask_image = mask_val.astype(np.uint8) * 255
mask
value is a list of boolean numpy arrays, in order to convert it to an image and display you can use:mask_val = result['mask'][0] mask_image = mask_val.astype(np.uint8) * 255
edit required in forward.py? where?
@bendangnuksung
mask_val = r['mask'][0] mask_image = mask_val.astype(np.uint8) * 255
cv2.imshow('mask', mask_image) cv2.waitKey(0) cv2.destroyAllWindows()
Traceback (most recent call last):
File "test.py", line 25, in
@bendangnuksung
result
is the variable you got after processing from the forward model.
result = [{'rois': array([[244, 287, 590, 721], [216, 737, 426, 925]], dtype=int32), 'class': array([1, 1], dtype=int32), 'scores': array([0.9834276 , 0.76979005], dtype=float32), 'mask': array([[[False, False], [False, False], [False, False], ...,
result
is the variable you got after processing from the forward model.
result = [{'rois': array([[244, 287, 590, 721], [216, 737, 426, 925]], dtype=int32), 'class': array([1, 1], dtype=int32), 'scores': array([0.9834276 , 0.76979005], dtype=float32), 'mask': array([[[False, False], [False, False], [False, False], ...,
mask_val = r['mask'][0] change required mask_val = r[0]['mask]
but error is
Traceback (most recent call last):
File "test.py", line 29, in
Invalid number of channels in input image: 'VScn::contains(scn)' where 'scn' is 2
convert it to mask_val = r[0]['mask'][0]
and see
convert it to
mask_val = r[0]['mask'][0]
and see
above line is working but, I have to show a masked image on my input image like this:
@bendangnuksung @bendangnuksung
from forward import ForwardModel import cv2 import numpy as np
frozen_graph_path = "/home/deepedge/mask_rcnn-master/mask_dent_frozen_graph.pb"
from config import mask_config my_config = mask_config(1)
forward_model = ForwardModel(frozen_graph_path, my_config)
def test_one_image(image): images = np.expand_dims(image, axis=0)
results = forward_model(images)
return results
if name == "main": test_image_path = '/home/deepedge/mask_rcnn-master/mask-rcnn-bottle-training-master/dataset/val/car39.jpg' image = cv2.imread(test_image_path) rr = test_one_image(image) from mrcnn import visualize from mrcnn import model r = model.detect([rr], verbose=0)[0] visualize.display_instances(rr, r['rois'], r['masks'], r['class_ids'], dataset.class_names, r['scores']) print(type(r))
i have used There is a function called "display_instances" in the script "mrcnn/visualize.py" to visualize the results : not working? @bendangnuksung
i am getting results like this, but how to display the result of image?
[{'rois': array([[244, 287, 590, 721], [216, 737, 426, 925]], dtype=int32), 'class': array([1, 1], dtype=int32), 'scores': array([0.9834276 , 0.76979005], dtype=float32), 'mask': array([[[False, False], [False, False], [False, False], ..., [False, False], [False, False], [False, False]],
@bendangnuksung @buaacarzp