amitkayal commited on
Commit
c1b499f
·
1 Parent(s): 144a4d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -74,6 +74,15 @@ def inference_visualization(input_img, transparency = 0.5, target_layer_number =
74
  visualization = show_cam_on_image(org_img/255, grayscale_cam, use_rgb=True, image_weight=transparency)
75
  return visualization
76
 
 
 
 
 
 
 
 
 
 
77
  title = "CIFAR10 trained on ResNet18 Model with GradCAM"
78
  description = "Gradio interface to infer on ResNet18 model, and get GradCAM results"
79
  examples = [["cat.jpg", 0.5, -1], ["dog.jpg", 0.5, -1]]
@@ -85,7 +94,7 @@ demo = gr.Interface(
85
  # title = title,
86
  # description = description,
87
  # examples = examples,
88
- fn=None, # We'll add the function later after defining all functions, # We'll add the function later after defining all functions
89
  inputs=[
90
  gr.Radio(["Yes", "No"], label="View GradCAM images?"),
91
  gr.Number(label="Number of GradCAM images to view", default=5, max=10),
@@ -106,15 +115,8 @@ demo = gr.Interface(
106
  live=True
107
  )
108
 
109
- # Callback function for the Gradio interface
110
- def gradio_callback(view_gradcam, num_gradcam_images, layer_name, opacity,
111
- view_misclassified, num_misclassified_images,
112
- input_img,submit):
113
- confidence = inference_confidences(input_img, transparency = 0.5, target_layer_number = -1)
114
- visualization = inference_visualization(input_img, transparency = 0.5, target_layer_number = -1)
115
- return confidence, visualization
116
 
117
 
118
  # Set the callback function to the Gradio interface
119
- demo.fn = gradio_callback
120
  demo.launch()
 
74
  visualization = show_cam_on_image(org_img/255, grayscale_cam, use_rgb=True, image_weight=transparency)
75
  return visualization
76
 
77
+ # Callback function for the Gradio interface
78
+ def gradio_callback(view_gradcam, num_gradcam_images, layer_name, opacity,
79
+ view_misclassified, num_misclassified_images,
80
+ input_img,submit):
81
+ confidence = inference_confidences(input_img, transparency = 0.5, target_layer_number = -1)
82
+ visualization = inference_visualization(input_img, transparency = 0.5, target_layer_number = -1)
83
+ return confidence, visualization
84
+
85
+
86
  title = "CIFAR10 trained on ResNet18 Model with GradCAM"
87
  description = "Gradio interface to infer on ResNet18 model, and get GradCAM results"
88
  examples = [["cat.jpg", 0.5, -1], ["dog.jpg", 0.5, -1]]
 
94
  # title = title,
95
  # description = description,
96
  # examples = examples,
97
+ fn=gradio_callback, # We'll add the function later after defining all functions, # We'll add the function later after defining all functions
98
  inputs=[
99
  gr.Radio(["Yes", "No"], label="View GradCAM images?"),
100
  gr.Number(label="Number of GradCAM images to view", default=5, max=10),
 
115
  live=True
116
  )
117
 
 
 
 
 
 
 
 
118
 
119
 
120
  # Set the callback function to the Gradio interface
121
+ # demo.fn = gradio_callback
122
  demo.launch()