video2agent 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- video2agent/__init__.py +3 -0
- video2agent/__main__.py +4 -0
- video2agent/bench.py +53 -0
- video2agent/bili_account.py +996 -0
- video2agent/bili_auth.py +206 -0
- video2agent/caption_verify.py +340 -0
- video2agent/captions.py +437 -0
- video2agent/cli.py +2031 -0
- video2agent/cloud.py +554 -0
- video2agent/compare.py +139 -0
- video2agent/config.py +285 -0
- video2agent/db.py +760 -0
- video2agent/digest.py +266 -0
- video2agent/discover.py +266 -0
- video2agent/errors.py +8 -0
- video2agent/export.py +307 -0
- video2agent/lazy.py +37 -0
- video2agent/links.py +228 -0
- video2agent/local_models.py +254 -0
- video2agent/media.py +543 -0
- video2agent/net.py +60 -0
- video2agent/perception.py +657 -0
- video2agent/pipeline.py +4310 -0
- video2agent/setup.py +44 -0
- video2agent/skills/video2agent/SKILL.md +166 -0
- video2agent/skills/video2agent/references/commands.md +27 -0
- video2agent/skills/video2agent/references/dsh.md +39 -0
- video2agent/skills/video2agent/references/evidence.md +12 -0
- video2agent/skills/video2agent/references/visual-types.md +16 -0
- video2agent/sources.py +335 -0
- video2agent/storage.py +293 -0
- video2agent/text.py +667 -0
- video2agent/util.py +324 -0
- video2agent/visual.py +613 -0
- video2agent/worker.py +75 -0
- video2agent-0.1.0.dist-info/METADATA +208 -0
- video2agent-0.1.0.dist-info/RECORD +40 -0
- video2agent-0.1.0.dist-info/WHEEL +4 -0
- video2agent-0.1.0.dist-info/entry_points.txt +3 -0
- video2agent-0.1.0.dist-info/licenses/LICENSE +202 -0
video2agent/__init__.py
ADDED
video2agent/__main__.py
ADDED
video2agent/bench.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
import statistics
|
|
5
|
+
import time
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from .config import Config
|
|
9
|
+
from .pipeline import evidence, overview, search
|
|
10
|
+
from .util import json_dumps
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _tokens(value: Any) -> int:
|
|
14
|
+
return max(1, len(json_dumps(value, indent=None)) // 4)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def run_bench(cfg: Config, video_id: str, queries: list[str], *, image_budget: int = 2) -> dict[str, Any]:
|
|
18
|
+
t0 = time.perf_counter()
|
|
19
|
+
ov = overview(cfg, video_id)
|
|
20
|
+
overview_ms = round((time.perf_counter() - t0) * 1000, 1)
|
|
21
|
+
rows = []
|
|
22
|
+
latencies = []
|
|
23
|
+
total_tokens = _tokens(ov)
|
|
24
|
+
for q in queries:
|
|
25
|
+
t = time.perf_counter()
|
|
26
|
+
result = search(cfg, q, video_id=video_id, limit=5)
|
|
27
|
+
ms = round((time.perf_counter() - t) * 1000, 1)
|
|
28
|
+
latencies.append(ms)
|
|
29
|
+
total_tokens += _tokens(result)
|
|
30
|
+
first = (result.get("results") or [None])[0]
|
|
31
|
+
ev = None
|
|
32
|
+
if first:
|
|
33
|
+
t = time.perf_counter()
|
|
34
|
+
ev = evidence(cfg, video_id=video_id, at_ms=first["start_ms"], image_budget=image_budget)
|
|
35
|
+
ev_ms = round((time.perf_counter() - t) * 1000, 1)
|
|
36
|
+
total_tokens += _tokens(ev)
|
|
37
|
+
else:
|
|
38
|
+
ev_ms = None
|
|
39
|
+
rows.append({"query": q, "search_ms": ms, "results": len(result.get("results") or []),
|
|
40
|
+
"evidence_ms": ev_ms, "evidence_images": len((ev or {}).get("images") or [])})
|
|
41
|
+
ordered = sorted(latencies)
|
|
42
|
+
p50 = statistics.median(ordered) if ordered else 0.0
|
|
43
|
+
p95 = ordered[min(len(ordered) - 1, max(0, math.ceil(len(ordered) * 0.95) - 1))] if ordered else 0.0
|
|
44
|
+
return {
|
|
45
|
+
"ok": True,
|
|
46
|
+
"video_id": video_id,
|
|
47
|
+
"title": ov.get("title"),
|
|
48
|
+
"queries": rows,
|
|
49
|
+
"latency_ms": {"overview": overview_ms, "search_p50": p50, "search_p95": p95},
|
|
50
|
+
"estimated_tokens": total_tokens,
|
|
51
|
+
"counts": ov.get("counts"),
|
|
52
|
+
"metrics": ov.get("metrics"),
|
|
53
|
+
}
|