Object Detection classifier using Image_ai (code)


Object Detection Techniques

Number of Boxes Comparison in different Algorithm

  1. YOLOv1: 98 boxes
  2. YOLOv2: ~1k
  3. OverFeat: ~1–2k
  4. SSD: ~8–26k
  5. RetinaNet: ~100k.

Python Module ImageAI

COCO DATASET — to train our model

# for pyhton<3 pip and >3 pip3type this in your terminal
pip3 install -q imageai
from imageai.Detection import ObjectDetection
import os
execution_path = os.getcwd()detector = ObjectDetection()
#dataset to train modeldetector.setModelPath(os.path.join(execution_path,"/resnet50_coco_best_v2.0.1.h5"))
#load and save the output the filedetections=detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "Akku.jpg"), output_image_path=os.path.join(execution_path , "output_file_name"))##give prediction likefor eachObject in detections:
print(eachObject["name"] , " : " , eachObject["percentage_probability"] )
#person : 90.98637104034424
#horse : 85.25654077529907
#pen : 83.02676677703857
Passenger movie
from imageai.Detection import VideoObjectDetection
import os
import cv2
execution_path = os.getcwd()#access you webcam
camera = cv2.VideoCapture(0)
detector = VideoObjectDetection()
detector.setModelPath(os.path.join(execution_path , "/resnet50_coco_best_v2.0.1.h5"))
video_path=detector.detectObjectsFromVideo(input_file_path=os.path.join(execution_path, "Akku.mp4"),
output_file_path=os.path.join(execution_path, "output_file_name"), frames_per_second=20, log_progress=True, minimum_percentage_probability=40, detection_timeout=120)
These are parameters of VideoObjectDetectionframes_per_second=20 : No of frame per secondlog_progress=True : show the processing like
Processing Frame : 1
minimum_percentage_probability=40 :determine the integrity of the detection resultsdetection_timeout=120





Software Engineer 👨‍💻

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Intro to Hidden Markov Models

Actor-Critic With TensorFlow 2.x [Part 2of 2]

Ensemble Learning to Improve Machine Learning Results

Sketch to color anime translation using Generative Adversarial Networks(GANs)

More Complicated Model Means Better Accuracy : Not really !

Mathematics behind Machine Learning — What should you learn?

Machine Learning-Based Drone Detection: Using Supervisely

A Beginner’s Guide to K Nearest Neighbor(KNN) Algorithm With Code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akash Kumar

Akash Kumar

Software Engineer 👨‍💻

More from Medium

Perform Sliced Inference and Detailed Error Analysis using Detectron2 Models

CV Series 4— Image Formation Part 3 (Theory)

Implement PageRank Algorithm

Data Types in Java Virtual Machine