feat: GDINO A+B — time-bounded search (9s vs 130s) + parameterized interval

This commit is contained in:
Accusys
2026-05-14 13:57:25 +08:00
parent 5a9b34f1c2
commit 159684331e
4 changed files with 82 additions and 18 deletions

View File

@@ -5,18 +5,20 @@ from PIL import Image
GDINO_URL = "http://localhost:5051/search"
DEFAULT_UUID = "aeed71342a899fe4b4c57b7d41bcb692"
def score(frames, prompt):
def score(frames, prompt, start_time=0, end_time=0):
prompt_lower = prompt.lower()
# Just do a single time-bounded search (not per frame)
# Time-bounded search using GDINO range (format "start-end")
search_range = f"{int(start_time)}-{int(end_time) if end_time > start_time else int(start_time) + 60}"
try:
resp = requests.post(GDINO_URL, json={
"file_uuid": DEFAULT_UUID,
"text": prompt_lower,
"limit": 3,
"start_time": 0,
"end_time": 0
}, timeout=30)
"uuid": DEFAULT_UUID,
"query": prompt_lower,
"range": search_range,
"interval": 10,
"threshold": 0.1,
}, timeout=60)
data = resp.json()
hits = data.get("hits", [])
n_hits = len(hits)
@@ -31,7 +33,7 @@ def score(frames, prompt):
return {
"agent": "GroundingDINO",
"score": score_val,
"reasoning": f"{n_hits} hits, best_score={best_score:.2f}, labels={dets_found[:3]}",
"reasoning": f"{n_hits} hits, range={search_range}, best={best_score:.2f}",
"details": {"n_hits": n_hits, "best_score": best_score}
}
except Exception as e: