Mask_rcnn: ModuleNotFoundError: No module named 'pycocotools' while running the MaskRCNN demo.py

Created on 3 Sep 2018  Â·  5Comments  Â·  Source: matterport/Mask_RCNN

Help me! Beginner here. when I first run the MaskRCNN demo.py - I face at lot of module no found errors; I solved most of them and I am a bit stuck here! I tried every resolution I could find online even reinstalled the pycocotools but it seems that anything I do doesn't fix it. Please help!

import mrcnn.model as modellib
import os
import sys
import random
import math
import numpy as np
import skimage.io
import matplotlib
import matplotlib.pyplot as plt
​

Root directory of the project

ROOT_DIR = os.path.abspath("../")
​

Import Mask RCNN

sys.path.append(ROOT_DIR) # To find local version of the library
from mrcnn import utils
import mrcnn.model as modellib
from mrcnn import visualize

Import COCO config

sys.path.append(os.path.join(ROOT_DIR, "samplescoco/")) # To find local version
import coco
​
%matplotlib inline
​

Directory to save logs and trained model

MODEL_DIR = os.path.join(ROOT_DIR, "logs")
​

Local path to trained weights file

COCO_MODEL_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")

Download COCO trained weights from Releases if needed

if not os.path.exists(COCO_MODEL_PATH):
utils.download_trained_weights(COCO_MODEL_PATH)
​

Directory of images to run detection on

IMAGE_DIR = os.path.join(ROOT_DIR, "images")

ModuleNotFoundError Traceback (most recent call last)
in ()
18 # Import COCO config
19 sys.path.append(os.path.join(ROOT_DIR, "samplescoco/")) # To find local version
---> 20 import coco
21
22 get_ipython().run_line_magic('matplotlib', 'inline')

f:AnacondaMask_RCNNsamples/cocococo.py in ()
40 # If the PR is merged then use the original repo.
41 # Note: Edit PythonAPI/Makefile and replace "python" with "python3".
---> 42 from pycocotools.coco import COCO
43 from pycocotools.cocoeval import COCOeval
44 from pycocotools import mask as maskUtils

ModuleNotFoundError: No module named 'pycocotools'

Most helpful comment

try
pip install -U scikit-image
pip install -U cython
pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI

All 5 comments

because your path is wrong. Give correct path to the root directory and log files and coco weight file.

How about this one? Really sorry I am still learning so I'll keep asking till I can make this work! Need your help. I got that first part running but this one I'm stuck again

AttributeError Traceback (most recent call last)
in ()
----> 1 class InferenceConfig(coco.CocoConfig):
2 # Set batch size to 1 since we'll be running inference on
3 # one image at a time. Batch size = GPU_COUNT * IMAGES_PER_GPU
4 GPU_COUNT = 1
5 IMAGES_PER_GPU = 1

AttributeError: module 'coco' has no attribute 'CocoConfig'

try
pip install -U scikit-image
pip install -U cython
pip install git+https://github.com/philferriere/cocoapi.git#egg=pycocotools^&subdirectory=PythonAPI

from tokenizer.ptbtokenizer import PTBTokenizer
ModuleNotFoundError: No module named 'tokenizer.ptbtokenizer'

for windows / mrcnn

try
pip install -U scikit-image
pip install -U cython
pip uninstall numpy
pip install numpy==1.8
pip install pycocotools-windows

Was this page helpful?
0 / 5 - 0 ratings