A Python library for evaluating the performance of digital human video generation models.
Project description
Evalatar
A Python library for evaluating the performance of digital human video generation models.
Introduction
Evalatar is a Python library specifically designed for evaluating the performance of digital human video generation models. It provides multiple evaluation metrics to help researchers and developers quantify the quality, identity consistency, synchronization, and other aspects of generated videos.
Supported Evaluation Metrics
- FID (Fréchet Inception Distance): Measures the distance between generated videos and real videos in feature space
- FVD (Fréchet Video Distance): Video version of FID that considers the temporal dimension
- CSIM (Cosine Similarity for Identity Matching): Evaluates identity consistency using InsightFace
- ASE (Average Semantic Error): Semantic error based on MediaPipe facial landmark detection
- SYNC (Audio-Visual Synchronization): Audio-video synchronization evaluation (based on SyncNet)
- IQA (Image Quality Assessment): No-reference image quality assessment
Installation
Using pip
pip install evalatar
From Source (Development)
To set up the project for development:
- Clone the repository:
git clone https://github.com/hanmostudy/evalatar.git
cd evalatar
- Install
uvif you haven't already:
# On macOS and Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
# On Windows:
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# Or using pip:
pip install uv
- Synchronize project dependencies using
uv:
uv sync
- Install PyTorch separately (can be GPU version):
# For CPU-only version
uv pip install torch==2.7.0 torchvision
# For CUDA 12.1 version
uv pip install torch==2.7.0+cu126 torchvision --index-url https://download.pytorch.org/whl/cu126
- Activate the environment:
source .venv/bin/activate # On Windows: .venv\Scripts\activate
Usage Examples
import evalatar
# Calculate FID score
fid_score = evalatar.calculate_fid(
real_videos_path="path/to/real/videos/*.mp4",
generated_videos_path="path/to/generated/videos/*.mp4",
batch_size=50,
dims=2048,
target_fps=30,
device=None # Auto-detect CUDA or CPU
)
# Calculate FVD score
fvd_score = evalatar.calculate_fvd(
real_video_pattern="path/to/real/videos/*.mp4",
fake_video_pattern="path/to/generated/videos/*.mp4",
num_frames=16,
model='videomae', # or 'i3d'
device='cuda' # or 'cpu'
)
# Calculate identity consistency
csim_score = evalatar.calculate_csim(
generated_videos_path="path/to/generated/videos/*.mp4",
reference_identity_path="path/to/reference/face.jpg",
device='cuda', # or 'cpu'
frame_sample_rate=1 # Sample 1 frame per second
)
# Calculate audio-video synchronization
sync_c_score = evalatar.calculate_sync_c("path/to/video.mp4")
sync_d_score = evalatar.calculate_sync_d("path/to/video.mp4")
# Calculate semantic error
ase_score = evalatar.calculate_ase(
real_videos_path="path/to/real/videos/*.mp4",
generated_videos_path="path/to/generated/videos/*.mp4",
device=None # Auto-detect CUDA or CPU
)
# Calculate video quality
iqa_score = evalatar.calculate_iqa(
generated_videos_path="path/to/generated/videos/*.mp4",
device=None, # Auto-detect CUDA or CPU
metric_name='brisque', # or 'maniqa'
frame_sample_rate=1 # Sample 1 frame per second
)
Running Tests
To test the metric calculation functions, you can run the test suite:
# Run all tests
python -m pytest tests/test_evalatar_metrics.py -v -s
# Run specific metric tests
python -m pytest tests/test_evalatar_metrics.py -v -s -m fid # FID tests only
python -m pytest tests/test_evalatar_metrics.py -v -s -m fvd # FVD tests only
python -m pytest tests/test_evalatar_metrics.py -v -s -m sync # Sync tests only
python -m pytest tests/test_evalatar_metrics.py -v -s -m ase # ASE tests only
python -m pytest tests/test_evalatar_metrics.py -v -s -m csim # CSIM tests only
python -m pytest tests/test_evalatar_metrics.py -v -s -m iqa # IQA tests only
The tests will automatically download a sample YouTube video for evaluation if it's not already present in the test assets.
Third-Party Components
This project incorporates components from several third-party open source projects:
-
SyncNet - Audio-visual synchronization neural network
- Location: src/evalatar/syncnet_python
- Original Author: Joon Son Chung
- License: MIT License
- Project URL: https://github.com/joonson/syncnet_python
-
CDFVD - For FVD (Fréchet Video Distance) calculations
- PyPI Package:
cd-fvd - License: MIT License
- PyPI Package:
-
PyTorch FID - For FID (Fréchet Inception Distance) calculations
- PyPI Package:
pytorch-fid - License: Apache License 2.0
- PyPI Package:
-
PyIQA - For IQA (Image Quality Assessment) calculations
- PyPI Package:
pyiqa - License: Apache License 2.0
- PyPI Package:
Troubleshooting
FVD Model Download Issues
Problem: When using FVD with VideoMAE model, you may encounter model download failures or loading errors. This is due to the VideoMAE model URL being changed to Hugging Face.
Solution:
-
Manually download the VideoMAE model from the new URL:
https://huggingface.co/OpenGVLab/InternVideoMAE_models/resolve/main/mae-g/vit_g_hybrid_pt_1200e_ssv2_ft.pth -
Place the downloaded model file in the appropriate cache directory:
~/.venv/Lib/site-packages/cdfvd/third_party/VideoMAEv2/ -
Alternatively, you can use the I3D model instead by specifying
model='i3d'in thecalculate_fvdfunction.
Dependencies
- Python >= 3.11, < 3.12
- MediaPipe
- OpenCV
- PyTorch
- And other dependencies listed in pyproject.toml
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Feel free to submit issues and pull requests to improve this project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file evalatar-0.1.0.tar.gz.
File metadata
- Download URL: evalatar-0.1.0.tar.gz
- Upload date:
- Size: 91.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f86e80f95ee3528d54b6a7b8b227eedde6a7ae13acc33be0c58561096e99fb6
|
|
| MD5 |
088aa4e97a0a2c401a03dc597b6cc34c
|
|
| BLAKE2b-256 |
bf312723c6c564761a6180ec581dc44700d64dac3caf2eb7bb8169845c5d090c
|
File details
Details for the file evalatar-0.1.0-py3-none-any.whl.
File metadata
- Download URL: evalatar-0.1.0-py3-none-any.whl
- Upload date:
- Size: 85.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a0591d40e72d4443f369ca2fc4e4c4df04ce5f30f305e9b0c9ff7e86320d24a
|
|
| MD5 |
028b88d38db056a3d37295275e7ce0e3
|
|
| BLAKE2b-256 |
35e319683aba7fe75b5a5878673eb73731f68af8f95e637c20592d87a3e9a94f
|