BhumikaMak commited on
Commit
f8576f8
·
1 Parent(s): 0c25380

Fix: Gallery return issue.

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -59,6 +59,7 @@ def load_yolo_model(version="yolov5"):
59
  model.cpu()
60
  return model
61
 
 
62
  # Main function for Grad-CAM visualization
63
  def process_image(image, yolo_versions=["yolov5"]):
64
  image = np.array(image)
@@ -70,7 +71,7 @@ def process_image(image, yolo_versions=["yolov5"]):
70
  transform = transforms.ToTensor()
71
  tensor = transform(img_float).unsqueeze(0)
72
 
73
- # Initialize list to store result images
74
  result_images = []
75
 
76
  # Process each selected YOLO model
@@ -96,13 +97,13 @@ def process_image(image, yolo_versions=["yolov5"]):
96
  renormalized_cam = scale_cam_image(renormalized_cam)
97
  renormalized_cam_image = show_cam_on_image(img_float, renormalized_cam, use_rgb=True)
98
 
99
- # Concatenate images
100
  final_image = np.hstack((rgb_img, cam_image, renormalized_cam_image))
101
- result_images.append((yolo_version, Image.fromarray(final_image)))
 
102
 
103
  return result_images
104
 
105
- # Gradio Interface
106
  interface = gr.Interface(
107
  fn=process_image,
108
  inputs=[
 
59
  model.cpu()
60
  return model
61
 
62
+ # Main function for Grad-CAM visualization
63
  # Main function for Grad-CAM visualization
64
  def process_image(image, yolo_versions=["yolov5"]):
65
  image = np.array(image)
 
71
  transform = transforms.ToTensor()
72
  tensor = transform(img_float).unsqueeze(0)
73
 
74
+ # Initialize list to store result images with captions
75
  result_images = []
76
 
77
  # Process each selected YOLO model
 
97
  renormalized_cam = scale_cam_image(renormalized_cam)
98
  renormalized_cam_image = show_cam_on_image(img_float, renormalized_cam, use_rgb=True)
99
 
100
+ # Concatenate images and prepare the caption
101
  final_image = np.hstack((rgb_img, cam_image, renormalized_cam_image))
102
+ caption = f"Results using {yolo_version}"
103
+ result_images.append((Image.fromarray(final_image), caption))
104
 
105
  return result_images
106
 
 
107
  interface = gr.Interface(
108
  fn=process_image,
109
  inputs=[