Spaces:
Sleeping
Sleeping
Christopher H.
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -195,31 +195,30 @@ def create_interface():
|
|
| 195 |
save_btn = gr.Button("Save Current Image Annotations", variant="primary")
|
| 196 |
clear_btn = gr.Button("Clear All Annotations", variant="secondary")
|
| 197 |
|
| 198 |
-
# Add status message
|
| 199 |
status_msg = gr.Markdown(label="Status")
|
| 200 |
|
| 201 |
# Event handlers
|
| 202 |
def handle_image_upload(bbox_data):
|
| 203 |
try:
|
| 204 |
if not bbox_data or not isinstance(bbox_data, tuple):
|
| 205 |
-
return None
|
| 206 |
|
| 207 |
image_path, annotations = bbox_data
|
| 208 |
if not image_path:
|
| 209 |
-
return None
|
| 210 |
|
| 211 |
logger.info(f"Handling upload for: {image_path}")
|
| 212 |
resized_path = annotation_mgr.process_upload(image_path)
|
| 213 |
|
| 214 |
if resized_path and os.path.exists(resized_path):
|
| 215 |
-
|
| 216 |
-
logger.info(debug_msg)
|
| 217 |
# Return the resized path and keep any existing annotations
|
| 218 |
return (resized_path, annotations)
|
| 219 |
else:
|
| 220 |
error_msg = "Failed to process image"
|
| 221 |
logger.error(error_msg)
|
| 222 |
-
return None
|
| 223 |
|
| 224 |
except Exception as e:
|
| 225 |
error_msg = f"Error in upload handler: {str(e)}"
|
|
@@ -230,7 +229,7 @@ def create_interface():
|
|
| 230 |
bbox_input.upload(
|
| 231 |
fn=handle_image_upload,
|
| 232 |
inputs=[bbox_input],
|
| 233 |
-
outputs=[bbox_input
|
| 234 |
)
|
| 235 |
|
| 236 |
save_btn.click(
|
|
|
|
| 195 |
save_btn = gr.Button("Save Current Image Annotations", variant="primary")
|
| 196 |
clear_btn = gr.Button("Clear All Annotations", variant="secondary")
|
| 197 |
|
| 198 |
+
# Add status message
|
| 199 |
status_msg = gr.Markdown(label="Status")
|
| 200 |
|
| 201 |
# Event handlers
|
| 202 |
def handle_image_upload(bbox_data):
|
| 203 |
try:
|
| 204 |
if not bbox_data or not isinstance(bbox_data, tuple):
|
| 205 |
+
return None, "No image uploaded"
|
| 206 |
|
| 207 |
image_path, annotations = bbox_data
|
| 208 |
if not image_path:
|
| 209 |
+
return None, "No image path provided"
|
| 210 |
|
| 211 |
logger.info(f"Handling upload for: {image_path}")
|
| 212 |
resized_path = annotation_mgr.process_upload(image_path)
|
| 213 |
|
| 214 |
if resized_path and os.path.exists(resized_path):
|
| 215 |
+
logger.info(f"Processed image path: {resized_path}")
|
|
|
|
| 216 |
# Return the resized path and keep any existing annotations
|
| 217 |
return (resized_path, annotations)
|
| 218 |
else:
|
| 219 |
error_msg = "Failed to process image"
|
| 220 |
logger.error(error_msg)
|
| 221 |
+
return None, error_msg
|
| 222 |
|
| 223 |
except Exception as e:
|
| 224 |
error_msg = f"Error in upload handler: {str(e)}"
|
|
|
|
| 229 |
bbox_input.upload(
|
| 230 |
fn=handle_image_upload,
|
| 231 |
inputs=[bbox_input],
|
| 232 |
+
outputs=[bbox_input]
|
| 233 |
)
|
| 234 |
|
| 235 |
save_btn.click(
|