ST-2 Injection (ST2I) is a video style transfer system built on top of Stable Diffusion. It supports:
- Single-video style transfer with temporal consistency (
run_styleid_v2v.py– referred to here as the ST2I video script). - Batch video style transfer over all content/style combinations (
run_styleid_v2v_batch.pyorrun_all.sh). - Baseline StyleID image/video stylization without temporal fusion (code under
styleid/). - Evaluation utilities for aesthetics, FVD, style similarity, and temporal consistency (
evaluation/).
run_styleid_v2v.py: Main ST2I video script – stylizes a single content video with a single style image usingStyleIDVideoPipeline.run_styleid_v2v_batch.py: Batch ST2I over all content folders and style images.run_all.sh: Bash wrapper that loops over content/style pairs and calls the ST2I video script.styleid_v2v/: Implementation ofStyleIDVideoPipeline(video extension ofStyleIDPipelinewith GMFlow-based temporal fusion).styleid/: Original StyleID image pipeline (StyleIDPipeline) and a baseline video driver (run_video_styleid.py).evaluation/: Scripts and helpers for quantitative evaluation (FVD, aesthetics, style similarity, temporal consistency).GMflow/: GMFlow optical flow model code (expects weights atgmflow/pretrained/gmflow_sintel-0c07dcb3.pth).configs/: Configuration files (currently minimal/empty).
Where this README says “ST2I video script”, it refers to the run_styleid_v2v.py entry point (kept under that filename for compatibility).
- Python: 3.10+ (recommended)
- CUDA GPU: Required for practical performance
- Create and activate a virtual environment (optional but recommended).
- Install dependencies:
pip install -r requirements.txt- Make sure you have the Stable Diffusion weights available via Hugging Face (e.g.
runwayml/stable-diffusion-v1-5) and that GMFlow weights are placed at:
gmflow/pretrained/gmflow_sintel-0c07dcb3.pthST2I expects a simple directory layout under a chosen --data_root:
data/
content/
<video_name>/
0001.png
0002.png
...
style/
style_1.png
style_2.jpg
...- Content video: A folder of numbered frames (
.pngor.jpg), e.g.data/content/car/0001.png. - Style image: A single image file in
data/style/, e.g.data/style/wave.png.
Use the ST2I video script (run_styleid_v2v.py) to style one video with one style:
python run_styleid_v2v.py \
--data_root ./data \
--content_name car \
--style_name wave.png \
--output_dir ./results \
--model_path runwayml/stable-diffusion-v1-5 \
--ddim_steps 50 \
--gamma 0.75 \
--temperature 1.5 \
--mask_strength 1.0 \
--fusion-strategy anchor_only \
--fusion-start-percent 0.5 \
--fusion-end-percent 1.0This will write stylized frames to:
results/wave_stylized_car/0001.png
results/wave_stylized_car/0002.png
...and save run metadata to results/wave_stylized_car/parameters.json.
Two options:
- Python batch driver (recommended for cross-platform use):
python run_styleid_v2v_batch.py \
--data_root ./data \
--output_dir ./results \
--model_path runwayml/stable-diffusion-v1-5 \
--ddim_steps 50 \
--gamma 0.75 \
--temperature 1.5 \
--mask_strength 1.0 \
--fusion-strategy anchor_only \
--fusion-start-percent 0.5 \
--fusion-end-percent 1.0- Bash wrapper (Linux/macOS):
bash run_all.shBoth iterate over all <content_name> in data/content/ and all style images in data/style/, skipping combinations that already have an output folder.
--ddim_steps: Number of DDIM inversion/sampling steps (higher = better quality, slower).--gamma: Query preservation strength (higher = more content structure preserved).--temperature: Attention temperature (higher = stronger stylization).--mask_strength: How strongly fusion masks influence the final blend between warped prior frames and the freshly stylized frame.--fusion-strategy:"anchor_only"or"anchor_and_prev"; whether to fuse only with the first (anchor) frame or also with the previous stylized frame.--fusion-start-percent/--fusion-end-percent: Portion of the denoising schedule ([0, 1]) where fusion is active.--without_init_adain: If set, disables AdaIN in the initial latent (more literal content, less style coupling).
If you want plain StyleID without temporal fusion (e.g., per-frame or single images), use the code under styleid/:
- Single images: Run
styleid/styleid_pipeline.pyas a script (see__main__at the bottom of that file). - Per-frame video baseline:
python styleid/run_video_styleid.py \
--content_path ./data/content \
--style_path ./data/style \
--output_dir ./results_baseline_styleidThis processes frames independently using StyleIDPipeline.
The evaluation/ folder contains helpers and scripts used for experiments:
frechet_video_distance/: FVD computation scripts.improved-aesthetic-predictor/: Aesthetic score predictor.style_similarity/: Style similarity analysis.temporal_consistency/: Temporal consistency metrics and ablations.
These scripts are mostly standalone; see their in-folder documentation and comments for usage details.
- The project is referred to as ST-2 Injection (ST2I) in this README.
- The original entry script name
run_styleid_v2v.pyis kept on disk for backward compatibility, but conceptually it is the ST2I video script for single-video temporal style transfer.