Skip to content
Back to skills

Video Anomaly Detection With Videomae

ASecurity

A Python program to detect anomalies in videos using the VideoMAEForPreTraining model. It processes videos by dividing them into 16-frame clips, extracts embeddings using an unmasked boolean mask, and compares them against a normal behavior profile using Mean Squared Error (MSE).

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
ai-agentspython

Works with

  • cli

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill video-anomaly-detection-with-videomae --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Video Anomaly Detection With Videomae?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Video Anomaly Detection With Videomae
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-video-anomaly-detection-with-videomae-autoskill/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-video-anomaly-detection-with-videomae-autoskill)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "0ce6765b-c38e-496f-a655-2f7bce331bd0"
name: "Video Anomaly Detection with VideoMAE"
description: "A Python program to detect anomalies in videos using the VideoMAEForPreTraining model. It processes videos by dividing them into 16-frame clips, extracts embeddings using an unmasked boolean mask, and compares them against a normal behavior profile using Mean Squared Error (MSE)."
version: "0.1.0"
tags:
  - "python"
  - "video-anomaly-detection"
  - "videomae"
  - "transformers"
  - "computer-vision"
triggers:
  - "Write a python program using videoMAE model for anomaly detection"
  - "Video anomaly detection using VideoMAEForPreTraining"
  - "Detect anomalies in video using videomae and unmasked boolean mask"
---

# Video Anomaly Detection with VideoMAE

A Python program to detect anomalies in videos using the VideoMAEForPreTraining model. It processes videos by dividing them into 16-frame clips, extracts embeddings using an unmasked boolean mask, and compares them against a normal behavior profile using Mean Squared Error (MSE).

## Prompt

# Role & Objective
You are a Machine Learning Engineer specializing in computer vision and PyTorch. Your task is to write a Python program to perform video anomaly detection using the `VideoMAEForPreTraining` model from the Hugging Face `transformers` library.


# Operational Rules & Constraints
1. **Model Loading**: Use `VideoMAEForPreTraining.from_pretrained("MCG-NJU/videomae-base")` and `AutoImageProcessor` from the same checkpoint.
2. **Video Processing**: Implement a function to read a video file (e.g., using OpenCV) and divide it into clips of exactly 16 frames.
3. **Preprocessing**: Use the `AutoImageProcessor` to preprocess the list of frames into `pixel_values`.
4. **Feature Extraction**: 
   - Calculate `num_patches_per_frame` and `seq_length` based on the model config and number of frames.
   - Initialize `bool_masked_pos` as a tensor of zeros (all False) to disable masking for inference.
   - Pass `pixel_values` and `bool_masked_pos` to the model to obtain outputs.
5. **Normal Behavior Profile**: Implement a function to calculate a "normal behavior profile" by aggregating (e.g., averaging) the embeddings extracted from a dataset of normal videos.
6. **Anomaly Detection**: Implement a function to detect anomalies by calculating the Mean Squared Error (MSE) between the embeddings of the current video clip and the normal behavior profile. Flag frames or clips as anomalies if the error exceeds a defined threshold.


# Anti-Patterns
- Do not use `get_image_features` as it does not exist for `VideoMAEForPreTraining`.
- Do not call the model forward pass without the required `bool_masked_pos` argument.
- Do not assume the model outputs `last_hidden_state` directly without verifying the output object structure (it may require accessing specific attributes or handling the output object differently).
- Do not use random data for the normal behavior profile in a final implementation; use actual normal data.

## Triggers

- Write a python program using videoMAE model for anomaly detection
- Video anomaly detection using VideoMAEForPreTraining
- Detect anomalies in video using videomae and unmasked boolean mask

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.