Skip to content

chen0040/keras-object-detection-web-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

keras-object-detection-web-api

A simple wrapper over keras object detection libraries and provide web api using flask

Usage

Detect objects in an image using YOLO algorithm

The demo code below can be found in keras_object_detection/demo/yolo_predict.py

The demo codes takes in the image keras_object_detection/demo/images/test.jpg and output the detected boxes with class labels

import os

import scipy
from matplotlib.pyplot import imshow

from keras_object_detection.library.yolo import YoloObjectDetector
from keras_object_detection.library.yolo_utils import generate_colors, draw_boxes

model_dir_path = 'keras_object_detection/models'

image_file = 'keras_object_detection/demo/images/test.jpg'

detector = YoloObjectDetector()
detector.load_model(model_dir_path)

image, out_scores, out_boxes, out_classes = detector.predict(image_file)

# Print predictions info
print('Found {} boxes for {}'.format(len(out_boxes), image_file))
# Generate colors for drawing bounding boxes.
colors = generate_colors(detector.class_names)
# Draw bounding boxes on the image file
draw_boxes(image, out_scores, out_boxes, out_classes, detector.class_names, colors)
# Save the predicted bounding box on the image
image.save("keras_object_detection/demo/out/images/test.jpg", quality=90)
output_image = scipy.misc.imread("keras_object_detection/demo/out/images/test.jpg")
imshow(output_image)

Below is the image before detection:

image-before

Here is the image after detection:

image-after

About

A simple wrapper over keras object detection libraries and provide web api using flask

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages