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.59k stars 2.19k forks source link

Exception: KeyError: 'donut' #123

Closed qualitaetsmuell closed 5 years ago

qualitaetsmuell commented 5 years ago

Hello, first of all I would like to thank you for your fantastic work!

I run the RetinaNet object detection model in Google Colab to detect persons only:

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( "drive/My Drive/Instagram/00_Models/resnet50_coco_best_v2.0.1.h5")
detector.loadModel()
custom_objects = detector.CustomObjects(person=True)

and

detections = detector.detectCustomObjectsFromImage(custom_objects=custom_objects, input_image = input_path, output_image_path = output_path, minimum_percentage_probability = 20)

This worked perfectly fine until I tried to detect people on this picture.

This is the error message I get:

KeyError: 'donut'

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)

in () 12 os.makedirs("drive/My Drive/Instagram/02_Boxed/" + bild_liste[0].split("/")[-2] + "/", exist_ok=True) ---> 13 detections = detector.detectCustomObjectsFromImage(custom_objects=custom_objects, input_image = input_path, output_image_path = output_path, minimum_percentage_probability = 20)

Interestingly enough, everything works fine if i'm trying to perform object detection with numpy array output:

_ ,detections = detector.detectCustomObjectsFromImage(custom_objects=custom_objects, input_image = input_path, output_type="array")

Is it possible that there is a spelling mistake in RetinaNets object types? Should it be called "donot" instead of "donut"?

OlafenwaMoses commented 5 years ago

Yes it is a spelling mistake. You can correct the typo in your installation of ImageAI by editing the code base of the installation.

OlafenwaMoses commented 5 years ago

Also see #114

naihe2010 commented 5 years ago

can pull this fix: https://github.com/OlafenwaMoses/ImageAI/pull/69