> ## Documentation Index
> Fetch the complete documentation index at: https://docs.edgeimpulse.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Visual regression

> Build a model that predicts a continuous value — like a fill level or angle — directly from images, and deploy it to an embedded device.

export const CardOpenStudioTutorial = ({href}) => <Card title="Skip straight to the project" icon="forward" href={href}>
    Skip the setup: clone a ready-to-use Edge Impulse project with the dataset, impulse, and trained model.
  </Card>;

Visual regression lets you train a model that outputs a continuous numeric value from an image, rather than a discrete class label. This is useful whenever you need to measure or estimate something from a visual input: a fill level in a container, the angle of a dial or knob, the degree of wear on a component, or any other quantity that lies on a scale.

By the end of this tutorial, you will have trained and tested a visual regression model using Edge Impulse Studio, using images of vial tubes filled to different levels as the example dataset.

<CardOpenStudioTutorial href="https://studio.edgeimpulse.com/public/571331/latest" />

## What You'll Need

* A free [Edge Impulse account](https://studio.edgeimpulse.com/signup?utm_source=docs\&utm_medium=internal\&utm_campaign=visual-regression-tutorial).
* Images of the object or scene you want to measure, each labeled with its numeric value. For this tutorial you can use the [Vial Tubes dataset](/datasets/image/vial-tubes) or collect your own.

## Getting Started

The quickest way to follow along is to clone the public project, which already contains the dataset, impulse design, and a trained model:

1. Open the [Vial Tubes public project](https://studio.edgeimpulse.com/public/571331/latest) in Edge Impulse Studio.
2. Click the **Clone this project** button in the top-right corner.
3. Follow the prompts to copy the project into your account.

If you'd rather start from scratch with your own data, [create a new project](https://studio.edgeimpulse.com/signup?utm_source=docs\&utm_medium=internal\&utm_campaign=visual-regression-tutorial) and continue with the steps below.

## Building the Project Pipeline

### Collect and label data

For visual regression, every image needs a numeric label — the value the model will learn to predict. In this dataset, images are labeled with the fill level of the vial (e.g., `0`, `0.5`, `1`, `1.5`, `2`), where `-1` indicates an empty or inverted vial.

<Frame caption="Labeled data samples with numeric regression values">
  <img src="https://mintcdn.com/edgeimpulse/s8dsOgJvVXspqLe-/.assets/images/regression-labelling.png?fit=max&auto=format&n=s8dsOgJvVXspqLe-&q=85&s=9d393546a90d34717b525ddf4db61b06" width="1198" height="414" data-path=".assets/images/regression-labelling.png" />
</Frame>

Consistent framing and lighting across your images will significantly improve model accuracy. Capture images across the full range of values you want to predict, and distribute them evenly across the Training and Test sets.

You can upload images using any of the standard Edge Impulse methods:

* [Collect directly from a phone or camera](/tutorials/topics/data/collect-image-data-phone)
* [Studio uploader](/studio/projects/data-acquisition/dataset/uploader)
* [CLI uploader](/tools/clis/edge-impulse-cli/uploader)
* [Ingestion API](/apis/ingestion)

For AI-assisted labeling of images with continuous values, see [AI labeling for regression](/studio/projects/data-acquisition/ai-labeling#image-labeling-with-gpt-4o).

<Frame caption="AI-assisted labeling for visual regression">
  <img src="https://mintcdn.com/edgeimpulse/7V7DYmlHwneiNhtD/.assets/images/ai-labeling-visual-regression.png?fit=max&auto=format&n=7V7DYmlHwneiNhtD&q=85&s=667de61d9a589bd310ba6cc648a291f0" width="931" height="1000" data-path=".assets/images/ai-labeling-visual-regression.png" />
</Frame>

### Create the impulse

Go to **Create Impulse** in the menu. Add an **Image** processing block and a **Regression** learning block.

<Frame caption="Impulse design for visual regression">
  <img src="https://mintcdn.com/edgeimpulse/s8dsOgJvVXspqLe-/.assets/images/regression-create-impulse.png?fit=max&auto=format&n=s8dsOgJvVXspqLe-&q=85&s=923ccb0d648a8c5052dc8161d9bbe16d" width="1422" height="468" data-path=".assets/images/regression-create-impulse.png" />
</Frame>

The Image processing block resizes your images and converts them to the format the model expects. A resolution of 96×96 pixels offers a good balance between accuracy and on-device performance — you can increase it if your target hardware allows.

Once the blocks are configured, click **Save Impulse**.

### Generate features

Open the **Image** section from the menu and click **Save parameters**, then navigate to the **Generate features** tab and click **Generate features**.

Edge Impulse will extract visual features from every image in the Training set. When complete, the [Feature Explorer](/studio/projects/processing-blocks/feature-explorer) shows a 2D projection of those features — images that look similar appear close together. For regression, you should see a smooth gradient across the feature space that correlates with the labeled values.

### Training the model

Navigate to the **Regression** section and click **Start training**. Edge Impulse trains a neural network that maps image features to a predicted numeric value.

After training you will see metrics including [Mean Absolute Error (MAE)](/knowledge/metrics/definitions#mean-absolute-error-mae) — the average difference between the predicted and true values across the test set. Lower MAE indicates better accuracy.

## Testing the Model

### Model testing

Go to **Model Testing** and click **Classify all**. Edge Impulse runs every image in the Test set through the trained model and displays the predicted value alongside the true label.

<Frame caption="Model testing results for visual regression">
  <img src="https://mintcdn.com/edgeimpulse/s8dsOgJvVXspqLe-/.assets/images/regression-testing.png?fit=max&auto=format&n=s8dsOgJvVXspqLe-&q=85&s=7a992731ad9f0e1c3bf9c2d92d269bdb" width="1600" height="797" data-path=".assets/images/regression-testing.png" />
</Frame>

Review the results to check whether predictions are within an acceptable tolerance for your application. If accuracy is lower than expected, consider:

* Collecting more images, especially near values where the model struggles.
* Increasing image resolution.
* Rebalancing the Training/Test split.
* Using the [EON Tuner](/studio/projects/eon-tuner) to automatically find better impulse configurations.

### Live classification

Connect a device or upload an image directly in the **Live classification** tab to test the model against new, unseen images in real time.

## Deploying the Model

Once you are satisfied with accuracy, go to **Deployment** to export the model for your target hardware. Edge Impulse supports a wide range of embedded targets — see the full list of [supported hardware](/hardware).

The regression block produces a single floating-point output per inference, which your application can read and act on directly (for example, triggering an alert when the predicted fill level drops below a threshold).

## Next Steps

* Explore the full [Vial Tubes dataset](/datasets/image/vial-tubes) page for dataset details and citation information.
* Read about the [Regression learning block](/studio/projects/learning-blocks/blocks/regression) to understand available configuration options.
* Browse [supported hardware](/hardware) to find the right deployment target for your project.
* [Create a new Edge Impulse project](https://studio.edgeimpulse.com/signup?utm_source=docs\&utm_medium=internal\&utm_campaign=visual-regression-tutorial) to apply visual regression to your own data.
