Skip to content

Instantly share code, notes, and snippets.

@dhenandi
Created May 2, 2021 17:03
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 dhenandi/cadd43b1fd3e923daa5c21f3691be1fa to your computer and use it in GitHub Desktop.
Save dhenandi/cadd43b1fd3e923daa5c21f3691be1fa to your computer and use it in GitHub Desktop.
pip install tensorflow==2.4.0
pip install opencv-python
pip install keras
pip install imageAI
from imageai.Detection import ObjectDetection
detector = ObjectDetection()
import urllib.request
urllib.request.urlretrieve(
'https://gitlab.com/andreass.bayu/imageai-repo/-/raw/master/yolo-tiny.h5', 'yolo-tiny.h5')
model_path = "yolo-tiny.h5"
input_path = "./image/image2.jpg"
output_path = "image-yolo-tiny.jpg"
detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath(model_path)
detector.loadModel()
detection = detector.detectObjectsFromImage(input_image=input_path, output_image_path=output_path)
for eachItem in detection:
print(eachItem["name"] , " : ", eachItem["percentage_probability"])
from IPython.display import Image
Image(filename='image-yolo-tiny.jpg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment