from imageai.Detection import ObjectDetection import os execution_path = os.getcwd() detector = ObjectDetection() detector.setModelTypeAsYOLOv3() # detector.setModelTypeAsRetinaNet() detector.setModelPath(os.path.join(execution_path , 'yolo.h5')) detector.loadModel() detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , 'cap20190925_074847D_6.jpg'), output_image_path=os.path.join(execution_path, 'image2new.jpg'), minimum_percentage_probability=50) print(detections, end='\n') for eachObject in detections: print(eachObject['name'] , ' : ', eachObject['percentage_probability']) # print("--------------------------------")