VFI is a video frame interpolation project with:
- A desktop app UI for running interpolation on videos.
- A training pipeline for learning a middle-frame predictor from triplet frames
(A, B, C). - Dataset preparation and evaluation scripts.
- PyInstaller packaging support for a Windows executable.
- Project Overview
- Repository Layout
- Prerequisites
- Installation
- Prepare Training Data
- Train the Model
- Evaluate a Trained Model
- Run the Desktop App
- Build Windows Executable
- Troubleshooting
The model is trained on triplets of frames where:
A.pngis the first frame.B.pngis the ground-truth middle frame.C.pngis the third frame.
Training uses a combined loss with pixel reconstruction, edge consistency, and confidence-map supervision. Checkpoints are saved every epoch, and the best validation model is written to models/best.pth.
app.py
data/
raw_videos/
triplets/
models/
notebooks/
train_colab.ipynb
scripts/
download_data.py
evaluate.py
prepare_dataset.py
validate_videos.py
build.py
src/
dataset.py
model.py
predict.py
train.py
video_utils.py
tests/
vfi.spec
- Python 3.10 or newer
- pip
- Windows (for
.exepackaging) - Optional GPU (CUDA) for faster training
Install runtime dependencies:
pip install -r requirements.txtInstall training dependencies:
pip install -r requirements-train.txtOptional (for packaging):
pip install pyinstallerSet your API key, then download videos:
set PEXELS_API_KEY=your_api_key_here
python scripts/download_data.py --count 30Place videos (.mp4, .mov, .avi, .mkv, .webm) in:
data/raw_videos/
python scripts/validate_videos.pyInvalid videos are moved into data/raw_videos/rejected/.
python scripts/prepare_dataset.pyThis generates subfolders in data/triplets/, each containing A.png, B.png, and C.png.
The training entrypoint is the train(config) function in src/train.py.
Run this one-liner from the project root:
python -c "from src.train import train; train({'data_dir':'data/triplets','epochs':50,'batch_size':8,'learning_rate':1e-4,'checkpoint_dir':'models','device':'cuda'})"If you do not have a GPU, use device='cpu'.
data_dir: triplet dataset path (usuallydata/triplets)epochs: number of training epochsbatch_size: training batch sizelearning_rate: optimizer learning ratecheckpoint_dir: checkpoint output directory (usuallymodels)device:cudaorcpu
- Per-epoch checkpoints:
models/epoch_<N>.pth - Best checkpoint:
models/best.pth
Run evaluation on a test triplet directory:
python scripts/evaluate.py --model_path models/best.pth --test_dir data/triplets --output_dir evaluation_output --device cpuThis prints PSNR/SSIM metrics and writes visual comparisons to evaluation_output/.
Start the app:
python app.pyIn the app, select:
- Input video
- Output path
- Model weights (default points to
models/best.pth)
pip install pyinstallerpython scripts/build.pyFinal executable:
dist/VFI.exe
Ensure models/best.pth exists before building (the spec bundles this file into the executable).
You can also train using the notebook in notebooks/train_colab.ipynb.
High-level flow:
- Install dependencies in Colab.
- Mount Google Drive.
- Clone the repository.
- Copy triplet data into
data/triplets. - Run training via
from src.train import train. - Copy
models/best.pthback to Drive.
No valid triplet subfolders found: runpython scripts/prepare_dataset.pyand confirm triplets exist.Model file not found: verifymodels/best.pthexists.- Slow training: reduce
batch_sizeon limited hardware or use GPU. - Packaging issues: reinstall PyInstaller and rebuild with
python scripts/build.py.