Spaces:
Running
Running
David Ko
commited on
Commit
ยท
e95c1b8
1
Parent(s):
cdc5e33
Fix: Update add_detected_objects to handle bbox as list or dict
Browse files
api.py
CHANGED
@@ -667,11 +667,25 @@ def add_detected_objects():
|
|
667 |
object_id = f"{image_id}_{str(uuid.uuid4())[:8]}"
|
668 |
|
669 |
# ๋ฐ์ด๋ฉ ๋ฐ์ค ์ ๋ณด ์ถ์ถ
|
670 |
-
bbox = obj.get('bbox',
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
675 |
|
676 |
# ๋ฐ์ด๋ฉ ๋ฐ์ค๋ฅผ ์ด๋ฏธ์ง ์ขํ๋ก ๋ณํ
|
677 |
x1_px = int(x1 * image_width)
|
|
|
667 |
object_id = f"{image_id}_{str(uuid.uuid4())[:8]}"
|
668 |
|
669 |
# ๋ฐ์ด๋ฉ ๋ฐ์ค ์ ๋ณด ์ถ์ถ
|
670 |
+
bbox = obj.get('bbox', [])
|
671 |
+
|
672 |
+
# ๋ฆฌ์คํธ ํํ์ bbox [x1, y1, x2, y2] ์ฒ๋ฆฌ
|
673 |
+
if isinstance(bbox, list) and len(bbox) >= 4:
|
674 |
+
x1 = bbox[0] / image_width # ์ ๊ทํ๋ ์ขํ๋ก ๋ณํ
|
675 |
+
y1 = bbox[1] / image_height
|
676 |
+
x2 = bbox[2] / image_width
|
677 |
+
y2 = bbox[3] / image_height
|
678 |
+
width = x2 - x1
|
679 |
+
height = y2 - y1
|
680 |
+
# ๋์
๋๋ฆฌ ํํ์ bbox {'x': x, 'y': y, 'width': width, 'height': height} ์ฒ๋ฆฌ
|
681 |
+
elif isinstance(bbox, dict):
|
682 |
+
x1 = bbox.get('x', 0)
|
683 |
+
y1 = bbox.get('y', 0)
|
684 |
+
width = bbox.get('width', 0)
|
685 |
+
height = bbox.get('height', 0)
|
686 |
+
else:
|
687 |
+
# ๊ธฐ๋ณธ๊ฐ ์ค์
|
688 |
+
x1, y1, width, height = 0, 0, 0, 0
|
689 |
|
690 |
# ๋ฐ์ด๋ฉ ๋ฐ์ค๋ฅผ ์ด๋ฏธ์ง ์ขํ๋ก ๋ณํ
|
691 |
x1_px = int(x1 * image_width)
|