mrprimenotes commited on
Commit
5258caa
·
verified ·
1 Parent(s): 6c49c31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -104,8 +104,8 @@ class AnnotationManager:
104
 
105
  def process_upload(self, image_path):
106
  """Process uploaded image"""
107
- if not image_path:
108
- logger.warning("No image path provided")
109
  return None
110
 
111
  try:
@@ -200,10 +200,14 @@ def create_interface():
200
  debug_output = gr.Textbox(label="Debug Info", interactive=False)
201
 
202
  # Event handlers
203
- def handle_image_upload(image_path):
204
  try:
205
- if not image_path:
206
  return None, "No image uploaded"
 
 
 
 
207
 
208
  logger.info(f"Handling upload for: {image_path}")
209
  resized_path = annotation_mgr.process_upload(image_path)
@@ -211,7 +215,8 @@ def create_interface():
211
  if resized_path and os.path.exists(resized_path):
212
  debug_msg = f"Processed image path: {resized_path}"
213
  logger.info(debug_msg)
214
- return resized_path, debug_msg
 
215
  else:
216
  error_msg = "Failed to process image"
217
  logger.error(error_msg)
 
104
 
105
  def process_upload(self, image_path):
106
  """Process uploaded image"""
107
+ if not isinstance(image_path, (str, bytes, os.PathLike)):
108
+ logger.warning(f"Invalid image path type: {type(image_path)}")
109
  return None
110
 
111
  try:
 
200
  debug_output = gr.Textbox(label="Debug Info", interactive=False)
201
 
202
  # Event handlers
203
+ def handle_image_upload(bbox_data):
204
  try:
205
+ if not bbox_data or not isinstance(bbox_data, tuple):
206
  return None, "No image uploaded"
207
+
208
+ image_path, annotations = bbox_data
209
+ if not image_path:
210
+ return None, "No image path provided"
211
 
212
  logger.info(f"Handling upload for: {image_path}")
213
  resized_path = annotation_mgr.process_upload(image_path)
 
215
  if resized_path and os.path.exists(resized_path):
216
  debug_msg = f"Processed image path: {resized_path}"
217
  logger.info(debug_msg)
218
+ # Return the resized path and keep any existing annotations
219
+ return (resized_path, annotations), debug_msg
220
  else:
221
  error_msg = "Failed to process image"
222
  logger.error(error_msg)