-
Notifications
You must be signed in to change notification settings - Fork 19
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
MD5.0 "ModuleNotFoundError: No module named 'utils' #70
Comments
Hi, You can fix this issue by cloning the yolov5 repository. So you could add this cell right after you Set PYTHONPATH to include CameraTraps and ai4eutils:
That should solve the ModuleNotFoundError but you may run into another problem when running: Initially, I got this output:
To get around this problem, you will have to modify the file '/usr/local/lib/python3.7/dist-packages/torch/nn/modules/upsampling.py' by commenting out the line 'recompute_scale_factor=self.recompute_scale_factor' as follows:
(Same issue was raised here: ultralytics/yolov5#6948) (Comment originally posted by obyrnemj) |
Thanks! I got the same error re recompute_scale_factor, but was able to make patch. For anyone wanting to keep everything in a Colab file, here is the sed command: !sed -i '154 s@recompute_scale_factor=self.recompute_scale_factor)@)@' /usr/local/lib/python3.7/dist-packages/torch/nn/modules/upsampling.py After making this patch, the new model is working great. (Comment originally posted by robertzak133) |
Closing since it seems like everyone found a solution here. FYI the patching solution is only stable for a particular release of PyTorch (i.e., it may stop working if stuff changes in that file), plus there are any number of other reasons that new versions of PyTorch and/or YOLOv5 could break MegaDetector compatibility, so all other things being equal, we recommend checking out the specific commit of YOLOv5 against which we've tested (c23a441c9df7ca9b1f275e8c8719c949269160d1), and installing PyTorch version 1.10.1 (instead of the most recent version). Our instructions for conda environments already handle this, but it would be great if a Colab user wanted to post instructions for setting up a Colab environment that matches our recommended conda environments. (Comment originally posted by agentmorris) |
I'm very eager to try the Yolov5 version of Megadetector.
I had success getting MD4.0 up on Google Colab, as shown in:
https://colab.research.google.com/github/microsoft/CameraTraps/blob/master/detection/megadetector_colab.ipynb
I tried just replacing the call to load the model from:
!wget -O /content/megadetector_v4_1_0.pb https://lilablobssc.blob.core.windows.net/models/camera_traps/megadetector/md_v4.1.0/md_v4.1.0.pb
To:
!wget -O /content/megadetector_v5a.0.0.pt https://github.com/microsoft/CameraTraps/releases/download/v5.0/md_v5a.0.0.pt
Also, call to run_detector_batch.py from:
!python /content/CameraTraps/detection/run_detector_batch.py megadetector_v4_1_0.pb "$images_dir" "$output_file_path" --recursive
To:
!python /content/CameraTraps/detection/run_detector_batch.py megadetector_v5a.0.0.pt "$images_dir" "$output_file_path" --recursive
But I get the following error:
19202 image files found in the input directory
PyTorch reports 1 available CUDA devices
GPU available: True
Traceback (most recent call last):
File "/content/CameraTraps/detection/pytorch_detector.py", line 17, in
from utils.general import non_max_suppression, scale_coords, xyxy2xywh
ModuleNotFoundError: No module named 'utils'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "run_detector_batch.py", line 655, in
main()
File "run_detector_batch.py", line 635, in main
quiet=args.quiet)
File "run_detector_batch.py", line 344, in load_and_run_detector_batch
detector = load_detector(model_file)
File "/content/CameraTraps/detection/run_detector.py", line 234, in load_detector
from detection.pytorch_detector import PTDetector
File "/content/CameraTraps/detection/pytorch_detector.py", line 20, in
raise ModuleNotFoundError('Could not import YOLOv5 functions.')
ModuleNotFoundError: Could not import YOLOv5 functions.
Is there something else I need to do to make MDv5 work on colab?
Thanks.
Issue cloned from Microsoft/CameraTraps, original issue posted by robertzak133 on Jul 16, 2022.
The text was updated successfully, but these errors were encountered: