Saturday 22 June 2019

TF OD


Python Packages
!pip install tensorflow numpy scipy pillow matplotlib h5py keras
!pip install opencv-python
Check PWD
import os
os.getcwd()


Keep trained dataset model and Image to PWD



from imageai.Detection import ObjectDetection
import os

execution_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5"))
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image.png"), output_image_path=os.path.join(execution_path , "image2new.jpg"), minimum_percentage_probability=30)

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

detectObjectsFromImage() -  function and parse in the path to our image, and the path to the new image which the function will save. Then the function returns an array of dictionaries with each dictionary corresponding to the number of objects detected in the image. Each dictionary has the properties name (name of the object),percentage_probability (percentage probability of the detection) and box_points ( the x1,y1,x2 and y2 coordinates of the bounding box of the object). 
RetinaNet which is appropriate for high-performance and high-accuracy demanding detection tasks.
ImageAI provides very convenient and powerful methods to perform object detection on images and extract each object from the image. The object detection class supports RetinaNet, YOLOv3 and TinyYOLOv3. To start performing object detection, you must download the RetinaNet, YOLOv3 or TinyYOLOv3 object detection model 

Types of ModelPath
RetinaNet (Size = 145 mb, high performance and accuracy, with longer detection time) 
YOLOv3 (Size = 237 mb, moderate performance and accuracy, with a moderate detection time) 
TinyYOLOv3 (Size = 34 mb, optimized for speed and moderate performance, with fast detection time) 
Download Link

No comments:

Post a Comment