Can a computer identify what's in an image? Development libraries like ImageAI make normally-complex Machine Learning tasks including object detection easier. This blog post will show how to build an image classification application using Python, Flask, and ImageAI. The application will receive inbound images with Twilio MMS and respond with a modified image segmented into detected objects and the model's detection confidence percentages.

Prerequisites

Setup

Activate a virtual environment in Python 3 and on the command line, run pip install Flask twilio and pip install -U tensorflow keras opencv-python imageai .

Your Flask app will need to be visible from the web so Twilio can send requests to it. Ngrok lets us do this. With it installed, run the following command in your terminal in the directory your code is in. Run ngrok http 5000 in a new terminal tab.

You should see the screen above. Grab that ngrok URL to configure your Twilio number.

Build the Object-Detecting Flask App