Download example.py from alok098/video-scope-classifier: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/alok098/video-scope-classifier/resolve/main/example.py
- Command line
-
hf download hf://alok098/video-scope-classifier/example.py
-
curl -L -o example.py https://huggingface.co/alok098/video-scope-classifier/resolve/main/example.py
1.01 kB
| """Demo: python example.py (needs numpy only)""" | |
| import sys | |
| from pathlib import Path | |
| here = Path(__file__).resolve().parent | |
| sys.path.insert(0, str(here / "src")) | |
| from intent.runtime import ScopeRuntime # noqa: E402 | |
| clf = ScopeRuntime.load(here / "models" / "scope_classifier") | |
| # At ingestion: index the video's subtitles (optional; improves the retrieval-shape and modality features). | |
| srt = """1 | |
| 00:00:05,000 --> 00:00:09,000 | |
| the striker scores the winning goal | |
| 2 | |
| 00:02:10,000 --> 00:02:14,000 | |
| fans celebrate in the stands | |
| """ | |
| clf.add_video("demo", srt, duration_s=300.0) | |
| for q in ["What is the video mainly about?", | |
| "What colour is the referee's shirt?", | |
| "What happens right after the winning goal?", | |
| "How many times does the crowd cheer in the video?", | |
| "what is the score shown at half time"]: | |
| r = clf.predict(q, "demo") | |
| print(f"{r['scope']:<6} {r['n_frames']:>2} frames p={r['confidence']:.2f} {r['modality']:<7} {q}") | |