- tensorflow
- numpy
- matplotlib
Install them by running pip install -r requirements.txt
Use MaskRCNNModel
class from maskrcnn.py
.
The class can be used as shown in the following example:
img_path = "/path/to/my/image"
# Provide the .pb model file path
graph_path = "/path/to/downloaded/pbmodel"
# Provide the .pbtxt label map file path
label_map = "/path/to/downloaded/pbmap"
model = MaskRCNNModel(graph_path, label_map)
out = model.run(img)
img = Image.fromarray(out)
img.show()
NOTE: the
run
method receives a numpy array with shape [H, W, C]. If you use the Image library to open the image, remember to also installpillow
.
An image with the intance segmentation should show up.
See json_handler
to see how to handle the model's output.
Provided by tensorflow in it's model zoo. Link here