> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/models/supported-models/v-jepa-2-1.md).

# V-JEPA 2.1

Train Meta's V-JEPA 2.1 video model for Action Recognition on Roboflow and run it through the Serverless Cloud API

Use Meta's [V-JEPA 2.1](https://github.com/facebookresearch/vjepa2) self-supervised video model for [Action Recognition](/models/supported-models.md#action-recognition). Roboflow fine-tunes the ViT-B encoder on your labeled video segments. The trained model returns a timeline of actions: each entry has a class, a start and end frame, and a confidence score. Several actions can overlap in time.

{% hint style="info" %}
V-JEPA 2.1 is in Beta and needs a paid plan.
{% endhint %}

## Train V-JEPA 2.1

{% stepper %}
{% step %}

### Label your videos

Create an Action Recognition [Project](https://docs.roboflow.com/datasets/create-and-upload/create-a-project), upload videos, and [label video segments](https://docs.roboflow.com/datasets/annotate/annotate/annotate-video-segments) with an action class. Put videos in both the train and valid splits. A test split is optional.

<figure><img src="https://3448603185-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fcmo9mhfIjYrvFFy1U7dk%2Fuploads%2Fgit-blob-60aeac197b79a3eaa88190f32cbdbff0fc83ab66%2Faction-recognition-annotation-editor.webp?alt=media" alt="Action Recognition video annotation editor with pick up leg, align leg screw, spin leg, and flip table segments on separate timeline rows"><figcaption><p>Each segment marks when an action class happens in the video.</p></figcaption></figure>
{% endstep %}

{% step %}

### Start a training

Generate a version and [train a model](/models/train/train-a-model.md). Pick V-JEPA 2.1 in the training picker.

The recommended video sampling is 384×384 frames, 64 frames per window, and 4 frames per second. Frame size must be a multiple of 16 pixels and the frame count must be even. Each full frame is resized to a square without cropping.
{% endstep %}

{% step %}

### Stop or resume

Training stops on its own when validation F1 stops improving. You can stop a training early: it finishes the current epoch and keeps the best checkpoint. You can later continue it from its last checkpoint.
{% endstep %}
{% endstepper %}

The training summary shows no time or credit estimate for V-JEPA 2.1. Auto-labeling with a V-JEPA 2.1 model is not supported.

## V-JEPA 2.1 API

{% stepper %}
{% step %}

### Get your API Key

Find your key on the [Roboflow API settings page](https://app.roboflow.com/settings/api) and make it available to your shell:

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}

### Install the dependencies

Install the [Inference SDK](https://docs.roboflow.com/deployment/self-hosted/self-hosted), version 1.5.2 or newer:

```bash
pip install -U inference-sdk
```

{% endstep %}

{% step %}

### Run the model

Send a whole video clip with your trained model's ID (see [Versions, Trainings, and Models](/models/versions-trainings-and-models.md)).

```python
import os
from inference_sdk import InferenceHTTPClient, InferenceConfiguration

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
).configure(InferenceConfiguration(api_key_transport="header"))

# Replace "your-project/1" with your model ID.
result = client.infer_on_video(
    "https://example.com/video.mp4",
    model_id="your-project/1",
)

for segment in result["timeline"]:
    start = segment["start_frame_idx"] / result["source_fps"]
    end = (segment["end_frame_idx"] + 1) / result["source_fps"]
    print(f"{segment['class']}: {start:.1f}s - {end:.1f}s ({segment['confidence']:.2f})")
```

{% endstep %}
{% endstepper %}

Each timeline entry has `class`, `class_id`, `start_frame_idx`, `end_frame_idx`, and `confidence`. Frame indices refer to the original video, start at zero, and include both ends. Spans of the same class that touch or overlap merge into one.

`infer_on_video` also accepts a local file path, but the file is sent as base64, so prefer a URL for long clips. To report only some classes, call `client.configure(InferenceConfiguration(class_filter=["walking"]))` before inferring.

{% hint style="info" %}
Set `api_url` to match your deployment target:

* `https://serverless.roboflow.com` for the Serverless Cloud API.
* `http://localhost:9001` for a local [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) server.
* Your [Dedicated Deployment](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) URL for a private endpoint.
  {% endhint %}

## Use V-JEPA 2.1 in a Workflow

Add the [Action Recognition Model](https://docs.roboflow.com/workflows/blocks/blocks/video-processing/action-recognition-model) block to a [Workflow](https://docs.roboflow.com/workflows) to run a trained V-JEPA 2.1 model on a video stream. The block buffers frames and outputs a timeline of actions as the stream plays. You can also [evaluate the trained model](/models/evaluate/evaluate-trained-models.md).

## Download Weights

You can download a trained V-JEPA 2.1 model as a `model.safetensors` file. See [Download Model Weights](/models/model-weights/download-roboflow-model-weights.md).

## License

Roboflow's V-JEPA 2.1 code is adapted from Meta's release under the MIT license. See [Model Licenses](/models/model-licenses.md#other-models).
