A semantic video compression framework that leverages Foundation Models (CLIP, CogVideoX, Flux) to enhance compressed video quality through multi-modal guidance including text captions, generative image/video enhancement, and audio-visual alignment.
MVSC integrates semantic understanding into the video compression pipeline. Instead of relying solely on traditional rate-distortion optimization, it uses:
The compression backbone is Scale-Space Flow (SSF2020) from CompressAI, optimized with a combined loss of MSE, BPP (bits per pixel), LPIPS (perceptual loss), and optional audio guidance losses (CLIP loss, direction loss).
Input Video
│
├──► Video Captioning (CogVLM2) ──► Text Prompt
│
├──► Video Compression (SSF2020) ──► Compressed Frames (x_rec)
│ │
│ ├──► Image Enhancement (Flux + ControlNet)
│ │ guided by Text Prompt
│ │
│ └──► Video Enhancement (CogVideoX)
│ guided by Text Prompt
│
└──► Audio Embedding (wav2clip / AudioCLIP) ──► Audio-Visual Loss
MVSC/
├── src/
│ ├── train.py # Training script
│ ├── eval_model.py # Evaluation and inference
│ ├── baseline/
│ │ └── ssf2020.py # Scale-Space Flow model
│ ├── utils/
│ │ ├── generate_text.py # Video captioning (CogVLM2)
│ │ ├── generate_image.py # Image generation (Stable Diffusion)
│ │ ├── generate_image2.py # Image enhancement (Flux + ControlNet)
│ │ ├── generate_video.py # Video generation (CogVideoX)
│ │ ├── losses.py # CLIP loss, direction loss, AudioCLIP loss
│ │ ├── audioclip.py # AudioCLIP model wrapper
│ │ ├── format_utils.py # PIL <-> Tensor conversion
│ │ └── dataprepare.py # Dataset preparation
│ └── metrics/
│ ├── calculate_lpips.py # LPIPS perceptual metric
│ └── calculate_fvd.py # Frechet Video Distance
├── CLIPVQA/ # CLIP-based Video Quality Assessment
│ ├── main.py # VQA training/testing entry point
│ ├── models/ # Spatial/temporal attention models
│ ├── configs/ # VQA configuration files
│ └── README.md
├── common_metrics_on_video_quality/ # Video quality metrics (FVD, SSIM, LPIPS, PSNR)
│ ├── demo.py
│ └── README.md
├── configs/
│ ├── train/config.yaml # Training configuration
│ └── test/config.yaml # Testing configuration
├── tools/
│ ├── train.sh # Training launch script
│ └── test.sh # Testing launch script
└── requirements.txt
torch >= 2.5.0
torchvision >= 0.20.0
diffusers >= 0.32.1
transformers >= 4.46.2
accelerate >= 1.1.1
compressai == 1.2.6
numpy == 1.26.0
SwissArmyTransformer >= 0.4.12
moviepy >= 2.0.0
scikit-video >= 1.1.11
imageio >= 2.35.1
imageio-ffmpeg >= 0.5.1
wav2clip
lpips
pytorch-msssim
decord
git clone <repo-url>
cd MVSC
pip install -r requirements.txt
The framework uses the following Foundation Models (downloaded automatically or specify local paths):
| Model | Purpose | Default Path |
|---|---|---|
| CogVLM2 | Video captioning | THUDM/cogvlm2-llama3-caption |
| CogVideoX | Video enhancement | THUDM/CogVideoX1.5-5B |
| FLUX.1-dev | Image enhancement base | black-forest-labs/FLUX.1-dev |
| Flux ControlNet Upscaler | Image enhancement control | jasperai/Flux.1-dev-Controlnet-Upscaler |
| AudioCLIP | Audio-visual alignment | AudioCLIP-Full-Training.pt |
Edit configs/train/config.yaml:
model: ssf2020
dataset: /path/to/vimeo_septuplet
epochs: 100
learning_rate: 0.0001
lmbda: 0.01
batch_size: 16
patch_size: 256
cuda: True
Run training:
bash tools/train.sh
# or
CUDA_VISIBLE_DEVICES=0 python src/train.py \
-d /path/to/vimeo_septuplet \
-m ssf2020 \
--lambda_mse 0.01 \
--lambda_lpips 0.01 \
--checkpoint /path/to/checkpoint.pth.tar # optional, resume training
Using pre-trained CompressAI models:
CUDA_VISIBLE_DEVICES=0 python src/eval_model.py pretrained \
/path/to/UVG/yuv \
/path/to/output \
-a ssf2020 \
-q 1,2,3,4,5,6,7,8 \
--v2v_model /path/to/CogVideoX-5B \
--controlnet_path /path/to/Flux.1-dev-Controlnet-Upscaler \
--basenet_path /path/to/FLUX.1-dev
Using a custom checkpoint:
CUDA_VISIBLE_DEVICES=0 python src/eval_model.py checkpoint \
/path/to/UVG/yuv \
/path/to/output \
-a ssf2020 \
-p /path/to/checkpoint.pth.tar
The evaluation outputs per-sequence JSON files containing:
| Metric | Description |
|---|---|
| PSNR (Y/U/V/RGB) | Peak Signal-to-Noise Ratio |
| MS-SSIM | Multi-Scale Structural Similarity |
| LPIPS | Learned Perceptual Image Patch Similarity |
| BPP | Bits Per Pixel |
| Bitrate | Bitrate in kbps |
The training objective is a Rate-Distortion Loss with multi-modal guidance:
L = λ_mse * MSE(x_hat, x) + BPP + λ_lpips * LPIPS(x_hat, x)
+ λ_audio * CLIP_loss(x_hat, audio_embed)
+ λ_direction * Direction_loss(x_hat, audio_embed)
A CLIP-based Video Quality Assessment model that uses semantic descriptors ("Excellent", "Good", "Poor") to predict video quality scores via spatial and temporal attention. See CLIPVQA/README.md.
Evaluation toolkit for video generation/compression quality with support for FVD (PyTorch & TensorFlow), SSIM, LPIPS, and PSNR. See common_metrics_on_video_quality/README.md.
Based on CompressAI — see license headers in source files for details.
8 commits
Python
100.0%
A semantic video compression framework that leverages Foundation Models (CLIP, CogVideoX, Flux) to enhance compressed video quality through multi-modal guidance including text captions, generative image/video enhancement, and audio-visual alignment.
MVSC integrates semantic understanding into the video compression pipeline. Instead of relying solely on traditional rate-distortion optimization, it uses:
The compression backbone is Scale-Space Flow (SSF2020) from CompressAI, optimized with a combined loss of MSE, BPP (bits per pixel), LPIPS (perceptual loss), and optional audio guidance losses (CLIP loss, direction loss).
Input Video
│
├──► Video Captioning (CogVLM2) ──► Text Prompt
│
├──► Video Compression (SSF2020) ──► Compressed Frames (x_rec)
│ │
│ ├──► Image Enhancement (Flux + ControlNet)
│ │ guided by Text Prompt
│ │
│ └──► Video Enhancement (CogVideoX)
│ guided by Text Prompt
│
└──► Audio Embedding (wav2clip / AudioCLIP) ──► Audio-Visual Loss
MVSC/
├── src/
│ ├── train.py # Training script
│ ├── eval_model.py # Evaluation and inference
│ ├── baseline/
│ │ └── ssf2020.py # Scale-Space Flow model
│ ├── utils/
│ │ ├── generate_text.py # Video captioning (CogVLM2)
│ │ ├── generate_image.py # Image generation (Stable Diffusion)
│ │ ├── generate_image2.py # Image enhancement (Flux + ControlNet)
│ │ ├── generate_video.py # Video generation (CogVideoX)
│ │ ├── losses.py # CLIP loss, direction loss, AudioCLIP loss
│ │ ├── audioclip.py # AudioCLIP model wrapper
│ │ ├── format_utils.py # PIL <-> Tensor conversion
│ │ └── dataprepare.py # Dataset preparation
│ └── metrics/
│ ├── calculate_lpips.py # LPIPS perceptual metric
│ └── calculate_fvd.py # Frechet Video Distance
├── CLIPVQA/ # CLIP-based Video Quality Assessment
│ ├── main.py # VQA training/testing entry point
│ ├── models/ # Spatial/temporal attention models
│ ├── configs/ # VQA configuration files
│ └── README.md
├── common_metrics_on_video_quality/ # Video quality metrics (FVD, SSIM, LPIPS, PSNR)
│ ├── demo.py
│ └── README.md
├── configs/
│ ├── train/config.yaml # Training configuration
│ └── test/config.yaml # Testing configuration
├── tools/
│ ├── train.sh # Training launch script
│ └── test.sh # Testing launch script
└── requirements.txt
torch >= 2.5.0
torchvision >= 0.20.0
diffusers >= 0.32.1
transformers >= 4.46.2
accelerate >= 1.1.1
compressai == 1.2.6
numpy == 1.26.0
SwissArmyTransformer >= 0.4.12
moviepy >= 2.0.0
scikit-video >= 1.1.11
imageio >= 2.35.1
imageio-ffmpeg >= 0.5.1
wav2clip
lpips
pytorch-msssim
decord
git clone <repo-url>
cd MVSC
pip install -r requirements.txt
The framework uses the following Foundation Models (downloaded automatically or specify local paths):
| Model | Purpose | Default Path |
|---|---|---|
| CogVLM2 | Video captioning | THUDM/cogvlm2-llama3-caption |
| CogVideoX | Video enhancement | THUDM/CogVideoX1.5-5B |
| FLUX.1-dev | Image enhancement base | black-forest-labs/FLUX.1-dev |
| Flux ControlNet Upscaler | Image enhancement control | jasperai/Flux.1-dev-Controlnet-Upscaler |
| AudioCLIP | Audio-visual alignment | AudioCLIP-Full-Training.pt |
Edit configs/train/config.yaml:
model: ssf2020
dataset: /path/to/vimeo_septuplet
epochs: 100
learning_rate: 0.0001
lmbda: 0.01
batch_size: 16
patch_size: 256
cuda: True
Run training:
bash tools/train.sh
# or
CUDA_VISIBLE_DEVICES=0 python src/train.py \
-d /path/to/vimeo_septuplet \
-m ssf2020 \
--lambda_mse 0.01 \
--lambda_lpips 0.01 \
--checkpoint /path/to/checkpoint.pth.tar # optional, resume training
Using pre-trained CompressAI models:
CUDA_VISIBLE_DEVICES=0 python src/eval_model.py pretrained \
/path/to/UVG/yuv \
/path/to/output \
-a ssf2020 \
-q 1,2,3,4,5,6,7,8 \
--v2v_model /path/to/CogVideoX-5B \
--controlnet_path /path/to/Flux.1-dev-Controlnet-Upscaler \
--basenet_path /path/to/FLUX.1-dev
Using a custom checkpoint:
CUDA_VISIBLE_DEVICES=0 python src/eval_model.py checkpoint \
/path/to/UVG/yuv \
/path/to/output \
-a ssf2020 \
-p /path/to/checkpoint.pth.tar
The evaluation outputs per-sequence JSON files containing:
| Metric | Description |
|---|---|
| PSNR (Y/U/V/RGB) | Peak Signal-to-Noise Ratio |
| MS-SSIM | Multi-Scale Structural Similarity |
| LPIPS | Learned Perceptual Image Patch Similarity |
| BPP | Bits Per Pixel |
| Bitrate | Bitrate in kbps |
The training objective is a Rate-Distortion Loss with multi-modal guidance:
L = λ_mse * MSE(x_hat, x) + BPP + λ_lpips * LPIPS(x_hat, x)
+ λ_audio * CLIP_loss(x_hat, audio_embed)
+ λ_direction * Direction_loss(x_hat, audio_embed)
A CLIP-based Video Quality Assessment model that uses semantic descriptors ("Excellent", "Good", "Poor") to predict video quality scores via spatial and temporal attention. See CLIPVQA/README.md.
Evaluation toolkit for video generation/compression quality with support for FVD (PyTorch & TensorFlow), SSIM, LPIPS, and PSNR. See common_metrics_on_video_quality/README.md.
Based on CompressAI — see license headers in source files for details.
8 commits
Python
100.0%