TransNetV2 PyTorch

raw JSON →
1.0.5 verified Fri May 01 auth: no python

PyTorch implementation of TransNetV2 for shot-based video scene detection. Version 1.0.5, updated regularly with bug fixes.

pip install transnetv2-pytorch
error ModuleNotFoundError: No module named 'transnetv2'
cause Library not installed or installed under a different name.
fix
Run 'pip install transnetv2-pytorch' (note the hyphen in package name).
error AttributeError: 'TransNetV2' object has no attribute 'predict_video'
cause Using an older version of the library or wrong import.
fix
Upgrade to latest version: 'pip install --upgrade transnetv2-pytorch' and check import path.
gotcha The predict_video method expects the video to be in a format readable by OpenCV. Ensure ffmpeg is installed for codec support.
fix Install ffmpeg or use a supported video container (e.g., mp4).
gotcha Model weights are downloaded on first use from the original TransNetV2 repository. Internet connection required.
fix Ensure internet access or pre-download weights manually.

Loads the model and predicts scene boundaries for a video file.

from transnetv2 import TransNetV2

model = TransNetV2()
predictions = model.predict_video("video.mp4")