A step-by-step tutorial that follows a Jupyter notebook on how to use Clarifai for image predictions.
This post is a detailed walkthrough of how to perform a simple image prediction using Clarifai's python API. Everything contained here is in the accompanying Jupyter notebook hosted on Github at the following links:
Let's get started! If you want to jump straight into the notebook, the only change you need to make is to add your own PAT. Once that is in place you can run the whole thing to get your predictions.
First, we need to install Clarifai's gRPC software and dependencies. Clarifai's current version requires protobuf 3.20.3 as a minimum, but we can also upgrade protobuf to the latest version.
os
to access file system commands like listing the contends of a directoryBytesIO
to steam files as a stream of bytes to be processedskimage
we'll run predict on the example images in skimage's data modulematplotlib.pyplot
to display the results as imagesPIL
"pillow," an "image processing library" used to send images to Clarifainumpy
to create a range of numbers%matplotlib
inline
as a "magic function" in python to have the resulting generated images stored in the notebook.
In this step we just need to import all the relevant parts of the Clarifai packages and instantiate them to eventually create the connection with Clarifai's servers.
Clarifai uses personal access tokens -PATs - to identify you as a user and let you access services.
We fill in the placeholder for PAT here
In this step we convert our images into a byte stream using BytesIO and the userDataObject called resources_pb2.
A step-by-step tutorial that follows a Jupyter notebook on how to use Clarifai for image predictions.
© 2023 Clarifai, Inc. Terms of Service Content TakedownPrivacy Policy
© 2023 Clarifai, Inc. Terms of Service Content TakedownPrivacy Policy