# Visual AI predictions

> Visual AI predictions - There are a variety of methods for making predictions from DataRobot's image
> models; use Base64 encoding and sample scripts to simplify.

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-04-24T16:03:56.610596+00:00` (UTC).

## Primary page

- [Visual AI predictions](https://docs.datarobot.com/en/docs/classic-ui/modeling/special-workflows/visual-ai/vai-predictions.html): Full documentation for this topic (HTML).

## Sections on this page

- [Base64 encoding format](https://docs.datarobot.com/en/docs/classic-ui/modeling/special-workflows/visual-ai/vai-predictions.html#base64-encoding-format): In-page section heading.
- [Sample scripts](https://docs.datarobot.com/en/docs/classic-ui/modeling/special-workflows/visual-ai/vai-predictions.html#sample-scripts): In-page section heading.
- [Deep dive](https://docs.datarobot.com/en/docs/classic-ui/modeling/special-workflows/visual-ai/vai-predictions.html#deep-dive): In-page section heading.

## Related documentation

- [Classic UI documentation](https://docs.datarobot.com/en/docs/classic-ui/index.html): Linked from this page.
- [Modeling](https://docs.datarobot.com/en/docs/classic-ui/modeling/index.html): Linked from this page.
- [Specialized workflows](https://docs.datarobot.com/en/docs/classic-ui/modeling/special-workflows/index.html): Linked from this page.
- [Visual AI](https://docs.datarobot.com/en/docs/classic-ui/modeling/special-workflows/visual-ai/index.html): Linked from this page.
- [Make Predictions tab](https://docs.datarobot.com/en/docs/classic-ui/modeling/analyze-models/predictions/predict.html): Linked from this page.
- [Deploy tab (UI)](https://docs.datarobot.com/en/docs/classic-ui/mlops/deployment/deploy-methods/deploy-model.html): Linked from this page.
- [Prediction API](https://docs.datarobot.com/en/docs/api/reference/predapi/legacy-predapi/dr-predapi.html): Linked from this page.
- [Batch prediction scripts](https://docs.datarobot.com/en/docs/classic-ui/predictions/batch/cli-scripts.html): Linked from this page.
- [Portable Prediction Server](https://docs.datarobot.com/en/docs/classic-ui/predictions/port-pred/pps/portable-pps.html): Linked from this page.
- [Getting Predictions for Visual AI Projects via API Calls](https://docs.datarobot.com/en/docs/api/dev-learning/python/py-code-examples/prediction-examples/vai-pred.html): Linked from this page.

## Documentation content

# Visual AI predictions

There are various methods for making predictions from image models:

| Method | Description | See... |
| --- | --- | --- |
| UI predictions | Use the same dataset format as the one used to create the project (upload a ZIP archive with one or more images). | Make Predictions tab |
| Model Deployment: API (real-time, small datasets) | Use the base64 format (described below). | Deploy tab (UI)Prediction API |
| Model Deployment: Batch (large datasets) | For the API Client and HTTP Interface options, use the same dataset format as the original dataset used to create the project (i.e., upload a ZIP archive with one or more images). For the CLI Interface option use the base64 format (described below). | Batch prediction scripts |
| Portable Prediction Server | Use the base64 format (described below). | Portable Prediction Server |

## Base64 encoding format

If your training dataset consists of a ZIP archive with one or more image files, the prediction dataset needs to be converted to a different format so that it is fully contained in a single CSV file.

## Sample scripts

See the links below for help with visual data conversion:

- Tutorial: Getting Predictions for Visual AI Projects via API Calls
- DataRobot Python package: Preparing data for predictions using the DataRobot library
- Script: Comprehensive data prep script

> [!NOTE] Note
> Log in to GitHub before accessing these GitHub resources.

The following shows sample usage:

`python visualai_data_prep.py pred_dataset.zip pred_dataset.csv image`

Where:

- visualai_data_prep.py is the comprehensive Data Prep script used for making conversions to base64 format.
- pred_dataset.zip is the input dataset (ZIP of images).
- pred_dataset.csv is the output, which can be used via prediction API.
- image is an image column name.

## Deep dive

To convert a set of image files into a single CSV file, each image must be converted to [base64 text](https://en.wikipedia.org/wiki/Base64). This format allows DataRobot to embed images as a regular text column in the CSV. Encoding binary image data into base64 is a simple operation, present in all programming languages.

Here is an example in Python:

```
import base64
import pandas as pd
from io import BytesIO
from PIL import Image


def image_to_base64(image: Image) -> str:
    img_bytes = BytesIO()
    image.save(img_bytes, 'jpeg', quality=90)
    image_base64 = base64.b64encode(img_bytes.getvalue()).decode('utf-8')
    return image_base64


# let's build a CSV with a single row that contains an image
# the same general approach works if you have multiple image rows or columns
image = Image.open('cat.jpg')
image_base64 = image_to_base64(image)

df = pd.DataFrame({'animal_image': [image_base64]})
df.to_csv('prediction_dataset.csv' index=False)
print(df)
```

> [!NOTE] Note
> Encode a binary image file (not decoded pixel contents) to base64. This example uses `PIL.Image` to open the file, but you can base64-encode an image file directly.
