Spaces:
Sleeping
Sleeping
Navy
commited on
Commit
·
a20a645
1
Parent(s):
0742e6c
fix bug file path
Browse files- core/defect_detection.py +4 -4
core/defect_detection.py
CHANGED
|
@@ -96,10 +96,10 @@ def detect_defect_from_video_url(station_id, camera_id: str, video_url: str, mod
|
|
| 96 |
frame_base64 = base64.b64encode(buffer).decode("utf-8")
|
| 97 |
|
| 98 |
# Save annotated image
|
| 99 |
-
|
| 100 |
# os.makedirs(output_dir, exist_ok=True)
|
| 101 |
-
|
| 102 |
-
|
| 103 |
# cv2.imwrite(filepath, frame)
|
| 104 |
# logger.info(f"[SAVED] NG image saved to {filepath}")
|
| 105 |
|
|
@@ -111,7 +111,7 @@ def detect_defect_from_video_url(station_id, camera_id: str, video_url: str, mod
|
|
| 111 |
"camera_id": camera_id,
|
| 112 |
"status_defect": "NG",
|
| 113 |
"image_base64": frame_base64,
|
| 114 |
-
|
| 115 |
"detections": [{
|
| 116 |
"class": defect_name,
|
| 117 |
"confidence": conf,
|
|
|
|
| 96 |
frame_base64 = base64.b64encode(buffer).decode("utf-8")
|
| 97 |
|
| 98 |
# Save annotated image
|
| 99 |
+
output_dir = "outputs/images"
|
| 100 |
# os.makedirs(output_dir, exist_ok=True)
|
| 101 |
+
filename = f"{station_id}_{camera_id}_NG_{datetime.now().strftime('%Y%m%d_%H%M%S')}.jpg"
|
| 102 |
+
filepath = os.path.join(output_dir, filename)
|
| 103 |
# cv2.imwrite(filepath, frame)
|
| 104 |
# logger.info(f"[SAVED] NG image saved to {filepath}")
|
| 105 |
|
|
|
|
| 111 |
"camera_id": camera_id,
|
| 112 |
"status_defect": "NG",
|
| 113 |
"image_base64": frame_base64,
|
| 114 |
+
"image_path": filepath,
|
| 115 |
"detections": [{
|
| 116 |
"class": defect_name,
|
| 117 |
"confidence": conf,
|