October 2018
Intermediate to advanced
472 pages
10h 57m
English
Now that we have all base code ready, let's deploy the ObjectDetection modules into production. In this section, we will write a RESTful service that will accept the image as an input and returns the detected object as a response.
We will define a POST function that accepts the image files with the PNG, JPG, JPEG, and GIF extensions. The uploaded image path is sent to the ObjectDetection module, which performs the detection and returns the following JSON results:
from flask import Flask, request, jsonify, redirectimport os , jsonfrom imageai.Detection import ObjectDetectionmodel_path = os.getcwd()PRE_TRAINED_MODELS = ["resnet50_coco_best_v2.0.1.h5"]# Creating ImageAI objects and loading modelsobject_detector = ObjectDetection() ...
Read now
Unlock full access