File size: 1,008 Bytes
162eceb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""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}")