Image recognition can seem like a pretty daunting technical challenge. Scraping images to use as training data for a machine learning model stresses me out. That’s where Clarifai comes in. This API is great for implementing image recognition so you can focus on the core functionality of what you are building.

Let’s build a Flask application in Python with Twilio MMS to receive picture messages over a phone number and respond with relevant keywords from Clarifai’s image recognition API.

Setting up your environment

Before moving on, make sure to have your Python environment setup. Getting everything working correctly, especially with respect to virtual environments, is important for isolating your dependencies if you have multiple projects running on the same machine.

You can also run through this guide to make sure you’re good to go before moving on.

Installing dependencies

Now that your environment is set up, you’re going to need to install the libraries we’ll use for this app:

Flask for our web framework

Twilio’s Python library to interact with the Twilio API

Clarifai’s Python library to interact with the Clarifai API for image recognition

First, navigate to the directory where you want this code to live and run the following command in your terminal with your virtual environment activated to install these dependencies: