[AZ-177] Remove redundant synchronous video pre-writes in /detect endpoint

Made-with: Cursor
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-04-01 01:12:05 +03:00
parent 22dd5db0d5
commit e65d8da6a3
5 changed files with 325 additions and 9 deletions
+3 -4
View File
@@ -391,8 +391,9 @@ async def detect_image(
if not ext.startswith("."):
ext = "." + ext
storage_path = os.path.abspath(os.path.join(base, f"{content_hash}{ext}"))
with open(storage_path, "wb") as out:
out.write(image_bytes)
if kind == "image":
with open(storage_path, "wb") as out:
out.write(image_bytes)
mt = "Video" if kind == "video" else "Image"
payload = {
"id": content_hash,
@@ -426,8 +427,6 @@ async def detect_image(
suf = ext if ext.startswith(".") else ".mp4"
fd, tmp_video_path = tempfile.mkstemp(suffix=suf)
os.close(fd)
with open(tmp_video_path, "wb") as f:
f.write(image_bytes)
save = tmp_video_path
inf.run_detect_video(image_bytes, ai_cfg, media_name, save, on_annotation)
else: