Arize AI
Search…
⌃K

Computer Vision (CV)

How to log your model schema for image classification models

CV Model Overview

Image classification models assign a label or class to an entire image. They take an image as input and return a prediction about which class it belongs to. Use this Colab to obtain embedding vectors from an image model using the well-known Fashion-MNIST dataset.
*all binary classification variant specifications are applicable to the CV model type, with the addition of embeddings

Performance Metric

MAP, IoU, Accuracy, Recall, Precision, FPR, FNR, F1, Sensitivity, Specificity

Examples

File Type
Link
Python Batch

CV Model Schema Parameters

Arize supports logging the prediction & actual category, and score, in addition to the embedding features associated with the image the model is acting on, and a link to the image itself so it can be rendered in the UI.
Arize Field
Data Type
Example
str
"prediction_id"
timestamp
str
"prediction_ts"
model_id
str
'sample-model-1'
str
'v1'
model_type
str
SCORE_CATEGORICAL
str
Environments.PRODUCTION
prediction_label
str | bool
"shoe"
prediction_score
float
0.6
actual_label
str | bool
"purse"
actual_score
float
0
embedding_feature_column_names
List[EmbeddingColumnNames]
[
EmbeddingColumnNames(
vector_column_name="image_embedding",
link_to_data_column_name="image_link"
)
]
In addition, the EmbeddingColumnNames class that Arize provides has its own fields described below,
Field
Data Type
Example
vector_column_name
str
"image_embedding"
link_to_data_column_name
str
"image_link"
The embedding vector is the dense vector representation of the unstructured input. The embedding link_to_data field is used to pass URL links to the source image your model is classifying.
Arize offers the Embedding class to construct your embedding objects. You can log them into the platform using a dictionary that maps the embedding feature names (how they will appear in the UI) to the embedding objects. See our API reference for more details.

Code Example

# Example embedding features
embedding_features = [
EmbeddingColumnNames(
vector_column_name="image_embedding",
link_to_data_column_name="image_link",
),
]
# Declare the schema of the dataframe you're sending (predictions, timestamp, actuals)
schema = Schema(
prediction_id_column_name="prediction_id",
timestamp_column_name="prediction_ts",
prediction_label_column_name="PREDICTION",
prediction_score_column_name="PREDICTION_SCORE",
actual_label_column_name="ACTUAL",
actual_score_column_name="ACTUAL_SCORE",
embedding_feature_column_names=embedding_features
)
# Log data into the Arize platform
response = arize_client.log(
model_id='sample-model-1',
model_version='v1',
model_type=ModelTypes.SCORE_CATEGORICAL,
environment=Environments.PRODUCTION,
dataframe=test_dataframe,
schema=schema
)
This example is for the python batch ingestion method, for other languages, please refer to our examples.

Prediction Label

"What does this image show?"
Label = "shoe"

Prediction Score

"How likely is this image to be showing a shoe?"
Score = 0.6

Actual Label

"What is this image actually showing"
Label = "purse"

Actual Score

"How likely is this image to be showing a shoe?"
Score = 0