You can perform shot boundary detection using the omnishotcut Python package. The API supports loading models from local paths or HuggingFace repositories and running inference on video files, numpy arrays, or torch tensors.
Loading a Model
Use omnishotcut.load() to initialize the model. You can specify a HuggingFace repo and a specific filename.
Running Inference
Call .inference() on the loaded model. The input can be a video file path, a numpy array, or a torch tensor with shape (T, H, W, 3) (RGB, uint8 or float [0, 1]).
Inference Modes
mode="clean_shot": Returns only clean cuts (no transitions). Returns a list of [start_frame, end_frame] pairs.mode="default": Returns clean cuts AND transitions (dissolves, wipes, fades) along with their labels. Returns (ranges, intra_labels, inter_labels).
import omnishotcut
# Load model from HuggingFace
cut_model = omnishotcut.load("uva-cv-lab/OmniShotCut_v1.5", filename = "OmniShotCut_ckpt.pth")
# Option 1: Clean shots only (returns list of [start, end])
ranges = cut_model.inference("video.mp4", mode="clean_shot")
# Option 2: Detailed detection (returns ranges, intra_labels, inter_labels)
ranges, intra_labels, inter_labels = cut_model.inference("video.mp4", mode="default")
# Option 3: Inference on raw frames (numpy or torch tensor)
# frames_thwc shape: (T, H, W, 3)
ranges = cut_model.inference(frames_thwc, mode="clean_shot")