OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.48k stars 2.18k forks source link

ModuleNotFoundError with Object Detection #791

Open LOActualControl opened 1 year ago

LOActualControl commented 1 year ago

Good evening,

When attempting to perform Object Detection using a pre-trained YoloV3 model, I am getting a ModuleNotFoundError. I'm attempting to detect a single class ("boat") from the 80 pre-trained classes available. My code is below (taken from the ImageAI documentation):

`from imageai.Detection import ObjectDetection

detector = ObjectDetection() detector.setModelTypeAsYOLOv3() detector.setModelPath("/content/gdrive/MyDrive/shipspotting_revision/yolov3.pt") detector.loadModel() custom = detector.CustomObjects(boat=True) detections = detector.detectCustomObjectsFromImage(custom_objects=custom, input_image="/content/gdrive/MyDrive/shipspotting_revision/rostock/output/livetest/test[1463].jpg", output_image_path="/content/gdrive/MyDrive/shipspotting_revision/rostock/output/live_test/test_new.jpg")

for eachObject in detections: print(eachObject["name"] , " : ", eachObject["percentage_probability"], " : ", eachObject["box_points"] ) `

The traceback for the error I'm getting is below:

ModuleNotFoundError Traceback (most recent call last) in 4 detector.setModelTypeAsYOLOv3() 5 detector.setModelPath("/content/gdrive/MyDrive/shipspotting_revision/yolov3.pt") ----> 6 detector.loadModel() 7 custom = detector.CustomObjects(boat=True) 8 detections = detector.detectCustomObjectsFromImage(custom_objects=custom, input_image="/content/gdrive/MyDrive/shipspotting_revision/rostock/output/livetest/test[1463].jpg", output_image_path="/content/gdrive/MyDrive/shipspotting_revision/rostock/output/live_test/test_new.jpg")

3 frames /usr/local/lib/python3.8/dist-packages/torch/serialization.py in find_class(self, mod_name, name) 1122 pass 1123 mod_name = load_module_mapping.get(mod_name, mod_name) -> 1124 return super().find_class(mod_name, name) 1125 1126 # Load the data (which may in turn use persistent_load to load tensors)

ModuleNotFoundError: No module named 'models'

All other imports were successful and I'm scratching my head as to what might be wrong. I'm working in a Colab notebook. Thanks for any help you can provide!