Download ComfyUI-ShotSplitter/tests/test_transnet.py from parlorsky/instara-models: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/parlorsky/instara-models/resolve/main/ComfyUI-ShotSplitter/tests/test_transnet.py
- Command line
-
hf download hf://parlorsky/instara-models/ComfyUI-ShotSplitter/tests/test_transnet.py
-
curl -L -o test_transnet.py https://huggingface.co/parlorsky/instara-models/resolve/main/ComfyUI-ShotSplitter/tests/test_transnet.py
1.75 kB
| """Smoke tests for TransNetV2 wrapper.""" | |
| import os | |
| import pytest | |
| from detectors.transnet import detect_transnet | |
| THREESHOT = "/workspace/ComfyUI/input/test_3shots.mp4" | |
| REEL = "/workspace/ComfyUI/input/reel_multishot.mp4" | |
| IMBA = "/workspace/ComfyUI/input/imba.mp4" | |
| def test_transnet_detects_synthetic_3shot_ground_truth(): | |
| boundaries = detect_transnet(THREESHOT, threshold=0.5) | |
| print(f"\n[info] TransNet on test_3shots.mp4: {boundaries}") | |
| assert len(boundaries) == 2, f"expected 2 cuts, got {len(boundaries)}: {boundaries}" | |
| # Ground truth: frame 60 and 120. Tolerance +/- 3 frames. | |
| assert 57 <= boundaries[0] <= 63, f"first cut expected ~60, got {boundaries[0]}" | |
| assert 117 <= boundaries[1] <= 123, f"second cut expected ~120, got {boundaries[1]}" | |
| def test_transnet_detects_at_least_one_cut_in_real_reel(): | |
| boundaries = detect_transnet(REEL, threshold=0.5) | |
| print(f"\n[info] TransNet on reel_multishot.mp4: {boundaries}") | |
| assert len(boundaries) >= 1, f"expected at least 1 cut in multi-shot reel, got {boundaries}" | |
| # PSD found 1 cut near frame 140. TransNet should agree on at least one cut there or nearby. | |
| def test_transnet_single_shot_returns_empty_or_one(): | |
| boundaries = detect_transnet(IMBA, threshold=0.5) | |
| print(f"\n[info] TransNet on imba.mp4: {boundaries}") | |
| # imba.mp4 is a single 8.7s phone video — expect 0, tolerate up to 1 (TransNet is sensitive) | |
| assert len(boundaries) <= 1, f"expected <=1 cut in single-shot video, got {boundaries}" | |