0

I want to acess m_rcnn.py file in jupyter notebook. The folder structure is as follows collab_mask_rcnn(working directory). Inside this workinhg directory i have a folder name maskrcnn_colab and inside this maskrcnn_colab folder i have another folder named mrcnn_demo where i have all the python file like m_rcnn.py, config.py located which i am trying to import

import sys
sys.path.append('C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo')
from m_rcnn import *

When i excute this i get the following error

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-3841d2b3769e> in <module>
      3 import sys
  4 sys.path.append("C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo")
----> 5 from m_rcnn import *

  6 get_ipython().run_line_magic('matplotlib', 'inline')

C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo\m_rcnn.py in <module>
     19 # Import Mask RCNN
     20 sys.path.append(ROOT_DIR)  # To find local version of the library
---> 21 from mrcnn_demo.config import Config
     22 from mrcnn_demo import utils
     23 import mrcnn_demo.model as modellib

ModuleNotFoundError: No module named 'mrcnn_demo'
 

What am i missing?

Kumar
  • 55
  • 3
  • Does your `mrcnn_demo` folder have an `mrcon_demo.py` in it (or another folder named `mrcom_demo` that has an `__init__.py` in it)? The path is a list of folders that *contain* modules, not a list of the modules themselves. Try lopping off the last directory. – kindall Nov 01 '22 at 11:46
  • @kindall there is no __init__.py file. m_rcnn.py file is in mrcnn_demo – Kumar Nov 01 '22 at 11:48

2 Answers2

0

I think you use sys.path.insert . Something like this:

from m_rcnn import *
import sys
sys.path.insert(1,'C:/Users/BIUTeamUser3/Desktop/collab_mask_rcnn/maskrcnn_colab/mrcnn_demo')


T. Bill
  • 11
  • 1
  • 1
  • 6
0

You might just try it like this:

from maskrcnn_colab.mrcnn_demo.m_rcnn import *
T. Bill
  • 11
  • 1
  • 1
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 04 '22 at 15:23