I am using this colab file to run mask rcnn object detection model. TensorFlow Hub Object Detection Colab
For visualization purposes it uses TensorFlow Object Detection API.
print('loading model...')
hub_model = hub.load(model_handle)
print('model loaded!')
# running inference
results = hub_model(image_np)
# different object detection models have additional results
# all of them are explained in the documentation
result = {key:value.numpy() for key,value in results.items()}
print(result.keys())
I don’t want to rely on object detection API. But I want to use models from thub. Now, how can I get instance wise segmentaiton mask for input image?
The results key above doesn’t have it. I’m expected to get instance mask as the following format.
(BATCH, HEIGHT, WITHD, DEPTH)
So, if a image contains 1 people, 2 dog, 1 cant, the shape would be
(1, HEIGHT, WIDTH, 4)
where, assume that,
1, HEIGHT, WITHD, 1 - for 1st people
1, HEIGHT, WITHD, 1 - for 2nd people
1, HEIGHT, WITHD, 1 - for 3rd people
1, HEIGHT, WITHD, 1 - for 4th people
But the results don’t give such formatted output.
result = {key:value.numpy() for key,value in results.items()}
print(result.keys())