Spaces:
Running
on
Zero
Running
on
Zero
Martin Tomov
commited on
adjustment output
Browse files
app.py
CHANGED
@@ -34,15 +34,21 @@ class DetectionResult:
|
|
34 |
|
35 |
@classmethod
|
36 |
def from_dict(cls, detection_dict: Dict) -> 'DetectionResult':
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
44 |
)
|
45 |
-
|
|
|
46 |
|
47 |
def annotate(image: Union[Image.Image, np.ndarray], detection_results: List[DetectionResult]) -> np.ndarray:
|
48 |
image_cv2 = np.array(image) if isinstance(image, Image.Image) else image
|
|
|
34 |
|
35 |
@classmethod
|
36 |
def from_dict(cls, detection_dict: Dict) -> 'DetectionResult':
|
37 |
+
# Debugging: Print the dictionary to see its structure
|
38 |
+
print("Detection Dictionary:", detection_dict)
|
39 |
+
try:
|
40 |
+
return cls(
|
41 |
+
score=detection_dict['score'],
|
42 |
+
label=detection_dict['label'],
|
43 |
+
box=BoundingBox(
|
44 |
+
xmin=detection_dict['box']['xmin'],
|
45 |
+
ymin=detection_dict['box']['ymin'],
|
46 |
+
xmax=detection_dict['box']['xmax'],
|
47 |
+
ymax=detection_dict['box']['ymax']
|
48 |
+
)
|
49 |
)
|
50 |
+
except KeyError as e:
|
51 |
+
raise ValueError(f"Missing key in detection dictionary: {e}")
|
52 |
|
53 |
def annotate(image: Union[Image.Image, np.ndarray], detection_results: List[DetectionResult]) -> np.ndarray:
|
54 |
image_cv2 = np.array(image) if isinstance(image, Image.Image) else image
|