Notebooks
A
Arize AI
Image Classification Tutorial

Image Classification Tutorial

multi_modalagentsllmsLlamaIndexarize-phoenixopenaitutorialsevalsllmopsai-monitoringaiengineeringprompt-engineeringdatasetsllm-evalai-observabilityllm-evaluationsmolagentsanthropiclangchain

Open In Colab

phoenix logo
Docs | GitHub | Community

Image Classification with Phoenix

In this tutorial, you will:

  • Upload a dataset of images to Phoenix
  • Create an experiment to classify the images and measure the accuracy of the model you use
  • View images in the Phoenix UI

ℹ️ This notebook requires an OpenAI API key.

Install dependencies

[ ]

Connect to Phoenix

[ ]
[ ]

Load dataset of test cases

[ ]
[ ]

We first need to convert the image data to a base64 encoded string. Phoenix expects the image data to be in either this format or as a URL.

[ ]

Next, let's map the numerical labels to the actual labels. This will make it easier to compare the model's output to the expected output.

[ ]
[ ]

Our dataset is now ready to upload to Phoenix. Let's take a look at the first image in the dataset just to make sure it looks right.

[ ]

From here, we can upload the dataset to Phoenix. This dataset will act as our test cases for the experiment we'll run later.

[ ]

Create our experiment task

[ ]

We'll be using OpenAI's GPT-4o-mini model to classify the images. Let's make sure we'll be able to properly see all the traces generated by this model by instrumenting it.

[ ]

We also need to set the OpenAI API key in the environment variables.

[ ]

Now we can define our task. This task will take an image and use GPT-4o-mini to classify it based on the labels we uploaded.

[ ]

Create our evaluators

Next, we have to set up our evaluators. In this case, our evaluators are very simple, because we have ground truth labels for each image. All we need to do is check if the model's output matches the expected output.

[ ]

Run our experiment

With that, we're ready to run our experiment. This function will run each row of our test_cases dataset through our task function and evaluate the output using our evaluators. Results will be displayed below, and uploaded to the Phoenix UI.

[ ]

If you're running this in Colab, you can view the experiment by clicking on the URL in the cell below.

[ ]