{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"%matplotlib inline","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from matplotlib import pyplot as plt\nfrom gluoncv import model_zoo, data, utils","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"net = model_zoo.get_model('mask_rcnn_fpn_resnet101_v1d_coco', pretrained=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from PIL import Image\nimport pandas as pd\nimport os\nimport numpy as np","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"image_file = os.listdir(\"../input/test/\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"pth = '../input/test/'+image_file[84822]\nImage.open(pth)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"x, orig_img = data.transforms.presets.rcnn.load_test(pth)\n\nids, scores, bboxes, masks = [xx[0].asnumpy() for xx in net(x)]\n\nwidth, height = orig_img.shape[1], orig_img.shape[0]\nmasks = utils.viz.expand_mask(masks, bboxes, (width, height), scores)\norig_img = utils.viz.plot_mask(orig_img, masks)\n\n# identical to Faster RCNN object detection\nfig = plt.figure(figsize=(20, 20))\nax = fig.add_subplot(1, 1, 1)\nax = utils.viz.plot_bbox(orig_img, bboxes, scores, ids,\n                         class_names=net.classes, ax=ax)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Need to go a long way.\n# see you soon. :)"},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.7.3"}},"nbformat":4,"nbformat_minor":1}