update from asus 106
This commit is contained in:
1 parent
6637fb1302
commit
8285400254
28 files changed
+3215
-459
No files matched your search
@@ -234,6 +234,38 @@ def replace_auto(frame_id: int, items: List[dict]) -> int:
|
||||
return len(items)
|
||||
|
||||
|
||||
def append_auto(frame_id: int, items: List[dict]) -> int:
|
||||
"""Add new automatic shapes to this frame without duplicating existing ones."""
|
||||
if not items:
|
||||
return 0
|
||||
existing = listing(frame_id)
|
||||
filtered_items = []
|
||||
for item in items:
|
||||
is_dup = False
|
||||
item_box = to_box(item["geometry"])
|
||||
for ex in existing:
|
||||
if ex["class_id"] == item["class_id"]:
|
||||
ex_box = to_box(ex["geometry"])
|
||||
from backend.labeling import _iou
|
||||
if _iou(item_box, ex_box) >= 0.85:
|
||||
is_dup = True
|
||||
break
|
||||
if not is_dup:
|
||||
filtered_items.append(item)
|
||||
|
||||
if not filtered_items:
|
||||
return 0
|
||||
|
||||
with db.cursor() as cur:
|
||||
cur.executemany(
|
||||
"""INSERT INTO annotations (frame_id, class_id, geometry, score, source, created_at)
|
||||
VALUES (?, ?, ?, ?, 'auto', ?)""",
|
||||
[(frame_id, item["class_id"], json.dumps(item["geometry"]),
|
||||
item.get("score", 1.0), time.time()) for item in filtered_items],
|
||||
)
|
||||
return len(filtered_items)
|
||||
|
||||
|
||||
def frames_with_auto(batch_id: int) -> set:
|
||||
"""Frame ids that already carry automatic shapes — the resume skip-list
|
||||
for REQ-035."""
|
||||
@@ -339,6 +371,24 @@ def clear_batch_class_annotations(batch_id: int, class_id: int) -> int:
|
||||
return cur.rowcount
|
||||
|
||||
|
||||
def clear_batch_auto_annotations(batch_id: int) -> int:
|
||||
"""Delete all automatic annotations (source = 'auto') for a batch and reset frame statuses."""
|
||||
with db.cursor() as cur:
|
||||
cur.execute(
|
||||
"""DELETE FROM annotations
|
||||
WHERE source = 'auto' AND frame_id IN (
|
||||
SELECT id FROM frames WHERE batch_id = ?
|
||||
)""",
|
||||
(batch_id,),
|
||||
)
|
||||
deleted = cur.rowcount
|
||||
cur.execute(
|
||||
"UPDATE frames SET review_status = 'pending' WHERE batch_id = ?",
|
||||
(batch_id,),
|
||||
)
|
||||
return deleted
|
||||
|
||||
|
||||
def _check_class(project_id: int, class_id: int) -> None:
|
||||
with db.cursor() as cur:
|
||||
cur.execute(
|
||||
|
||||
Reference in new issue
Block a user