Not-Adam commited on
Commit
ad3fae5
1 Parent(s): 5a8ad8e

Basic Cropped Error Handling (#3)

Browse files

- Basic Cropped Error Handling (b7be33d915fa3003937a34cce019a7fba3054c63)

Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -509,14 +509,17 @@ def get_cropped_images(images, category):
509
  cropped_list = []
510
  resultsPerCategory = {}
511
  for num, image in enumerate(images):
512
- image = open_image_from_url(image)
513
- class_counts, output_img, cropped_images, cropped_classes = get_objects(image, 0.37)
514
-
515
- if not class_counts:
516
- continue
517
-
518
- for i, image in enumerate(cropped_images):
519
- cropped_list.append(image)
 
 
 
520
 
521
  # Convert cropped images to base64 strings
522
  base64_images = encode_images_to_base64(cropped_list)
@@ -545,4 +548,4 @@ iface = gr.Interface(
545
  )
546
 
547
  # Launch the interface
548
- iface.launch()
 
509
  cropped_list = []
510
  resultsPerCategory = {}
511
  for num, image in enumerate(images):
512
+ try:
513
+ image = open_image_from_url(image)
514
+ class_counts, output_img, cropped_images, cropped_classes = get_objects(image, 0.37)
515
+
516
+ if not class_counts:
517
+ continue
518
+
519
+ for i, image in enumerate(cropped_images):
520
+ cropped_list.append(image)
521
+ except Exception as e:
522
+ print(f"Error processing image {num}: {e}")
523
 
524
  # Convert cropped images to base64 strings
525
  base64_images = encode_images_to_base64(cropped_list)
 
548
  )
549
 
550
  # Launch the interface
551
+ iface.launch()