Skip to content

Instantly share code, notes, and snippets.

@Ahanmr
Created June 19, 2018 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ahanmr/477a1d5fab525ab11508f173d4a73518 to your computer and use it in GitHub Desktop.
Save Ahanmr/477a1d5fab525ab11508f173d4a73518 to your computer and use it in GitHub Desktop.
'''
Editor: Ahan M R
Date: 18-06-2018
Python 3.6.0
'''
#PS1 CROWD DETECTION IN THE SITUATION
'''
From imageAI API, we import Object detection and use it to detect the object classes in the image
'''
from imageai.Detection import ObjectDetection
import os
#os.getcwd gets the current working directory of the image
execution_path = os.getcwd()
detection = ObjectDetection()
detection.setModelTypeAsRetinaNet()
detection.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5"))
detection.loadModel()
detections = detection.detectObjectsFromImage(input_image=os.path.join(execution_path , "image.jpg"), output_image_path=os.path.join(execution_path , "imagenew.jpg"))
for eachObject in detections:
print(eachObject["name"] + " : " + eachObject["percentage_probability"] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment