Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error , no module named SimpleHrnet #3

Closed
timtensor opened this issue Jun 3, 2019 · 7 comments
Closed

Import error , no module named SimpleHrnet #3

timtensor opened this issue Jun 3, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@timtensor
Copy link

timtensor commented Jun 3, 2019

Hi @stefanopini i seem to unable to import the simple Hrnet module . I have the following error
I was wondering , if i have missed some steps or additional confguration . I am running on a virtual machine with ubuntu 16.04

Traceback (most recent call last):
  File "scripts/live-demo.py", line 6, in <module>
    from SimpleHRNet import SimpleHRNet
ImportError: No module named SimpleHRNet

My directory structure is similar to yours

── datasets
│   ├── COCO.py
│   └── LiveCamera.py
├── LICENSE
├── misc
│   └── utils.py
├── models
│   ├── detectors
│   │   ├── yolo
│   │   │   ├── assets
│   │   │   │   ├── dog.png
│   │   │   │   ├── giraffe.png
│   │   │   │   ├── messi.png
│   │   │   │   └── traffic.png
│   │   │   ├── config
│   │   │   │   ├── coco.data
│   │   │   │   ├── create_custom_model.sh
│   │   │   │   ├── custom.data
│   │   │   │   ├── yolov3.cfg
│   │   │   │   └── yolov3-tiny.cfg
│   │   │   ├── data
│   │   │   │   ├── coco.names
│   │   │   │   ├── custom
│   │   │   │   │   ├── classes.names
│   │   │   │   │   ├── images
│   │   │   │   │   │   └── train.jpg
│   │   │   │   │   ├── labels
│   │   │   │   │   │   └── train.txt
│   │   │   │   │   ├── train.txt
│   │   │   │   │   └── valid.txt
│   │   │   │   ├── get_coco_dataset.sh
│   │   │   │   └── samples
│   │   │   │       ├── dog.jpg
│   │   │   │       ├── eagle.jpg
│   │   │   │       ├── field.jpg
│   │   │   │       ├── giraffe.jpg
│   │   │   │       ├── herd_of_horses.jpg
│   │   │   │       ├── messi.jpg
│   │   │   │       ├── person.jpg
│   │   │   │       ├── room.jpg
│   │   │   │       └── street.jpg
│   │   │   ├── detect.py
│   │   │   ├── LICENSE
│   │   │   ├── models.py
│   │   │   ├── README.md
│   │   │   ├── requirements.txt
│   │   │   ├── test.py
│   │   │   ├── train.py
│   │   │   ├── utils
│   │   │   │   ├── augmentations.py
│   │   │   │   ├── datasets.py
│   │   │   │   ├── __init__.py
│   │   │   │   ├── logger.py
│   │   │   │   ├── parse_config.py
│   │   │   │   └── utils.py
│   │   │   └── weights
│   │   │       ├── darknet53.conv.74
│   │   │       ├── download_weights.sh
│   │   │       ├── yolov3-tiny.weights
│   │   │       └── yolov3.weights
│   │   └── YOLOv3.py
│   ├── hrnet.py
│   └── modules.py
├── README.md
├── requirements.txt
├── scripts
│   └── live-demo.py
├── SimpleHRNet.py
├── SimpleHRNet.pyc
├── weights
│   └── pose_hrnet_w48_384x288.pth
└── workout_mod.mp4
@stefanopini
Copy link
Owner

Hi! To import the simpleHRNet module, you need to have the project root path (i.e. the directory with the file SimpleHRNet.py) in your "python path" (i.e. the path in which python search the packages).
By default, the working directory is automatically added to your "python path" so it should work if you run the script from the project root with the command python scripts/live-demo.py .

On Linux, you can check it running the command python -c "import sys;print(sys.path)": you should find your working directory in the printed list. (On Windows, the working directory is represented with an empty string.)
If you don't find it, just add the project root path to the environment variable PYTHONPATH.

@timtensor
Copy link
Author

timtensor commented Jun 4, 2019

Hi @stefanopini ,Ok i think i understand you . I did a print out of the system configuration which i do have the root folder
['', '/home/pm/pf/simple-HRNet/datasets', '/home/pm/pf/simple-HRNet/misc', '/home/pm/pf/simple-HRNet/models', '/home/pm/pf/simple-HRNet/__pycache__', '/home/pm/pf/simple-HRNet/scripts', '/home/pm/pf/simple-HRNet/test', '/home/pm/pf/simple-HRNet/weights', '/home/pm', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/pm/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/pyOpenSSL-19.0.0-py2.7.egg', '/usr/lib/python2.7/dist-packages']

However i have two versions of python ,python3.5andpython2.7` . Do you think it interferes ??

@stefanopini
Copy link
Owner

Yes, it could because I didn't test the script on python 2.7... You should use python 3.
Can you try to run the software using python3 scripts/live-demo.py?
In any case, I suggest you to use a virtual environment (see https://docs.python.org/3.7/tutorial/venv.html).

@timtensor
Copy link
Author

timtensor commented Jun 5, 2019

Hi @stefanopini , as you suggested i created a virtua enviroment . I see an error from the yolo model and running on python3.6
The error is as follows
Traceback (most recent call last):

  File "<stdin>", line 1, in <module>
  File "/home/test/simple-HRNet/SimpleHRNet.py", line 6, in <module>
    from models.detectors.YOLOv3 import YOLOv3
  File "/home/test/simple-HRNet/models/detectors/YOLOv3.py", line 7, in <module>
    from .yolo.models import Darknet
  File "/home/test/simple-HRNet/models/detectors/yolo/models.py", line 9, in <module>
    from utils.parse_config import *
ModuleNotFoundError: No module named 'utils'

The above error seems to be of yolo module , so i am not sure what is the problem
the output of the sys path is as follows

'/home/test/simple-HRNet', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/test/simple-HRNet/simpleHrnet/lib/python3.6/site-packages']

@stefanopini
Copy link
Owner

You're right, there was a bug on the yolo import... I should have just fixed it.
Let me know if it works now.

@timtensor
Copy link
Author

timtensor commented Jun 10, 2019

@stefanopini finally i managed to run the script but modying the sys path in the file ``/live-demo.py ` .

import sys 
sys.path.append("/home/test/simple-HRNet")

Maybe it is a dirty solution but seems to work .
and running the following , I still need to specify the --weights flag . However , when i run it , in a CUDA enabled device , i still get CUDA 0 and was wondering how can i get the venv access the CUDA. Do i have to install the CUDA toolkit for the venv ?? And did you have some ideas as in how to optimzie the detections ??
We get the following printout of torch.cuda.is_available()
True cuda:0
Does it mean it is accesing the CUDA drivers ? the output frame rate seems to very slow .

@stefanopini
Copy link
Owner

Dear @timtensor , I've finally been able to reproduce the error and fix it. It was related to different sys.path initialization between anaconda and non-anaconda environments.
Thank you for sharing your code. Indeed, my workaround is similar to yours, but it works regardless of the path of the project.

Regarding CUDA, you just need to install pytorch with CUDA support. If the script outputs cuda:0, it means that the GPU 0 (with CUDA support) is used to execute the network.
If you need further support, please open a specific issue (e.g. "frame rate is very low").

@stefanopini stefanopini added the bug Something isn't working label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants