OmerFarooq commited on
Commit
0c7cb71
1 Parent(s): be2c21d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -16
app.py CHANGED
@@ -149,24 +149,28 @@ def get_grad(img):
149
  text = "Raw Score: " + str(y_pred[0]) + "\nClassification: " + infer
150
  return grad_img_c, grad_img_d, text
151
 
152
- # demo = gr.Interface(
153
- # fn = get_grad,
154
- # with gr.Row():
155
- # inputs = gr.Image(type = "pil", shape = (224,224), width = 320, height = 320),
156
- # outputs = [gr.Image(type = "numpy", width = 320, height = 320, label = "Grad_CAM w.r.t cat"), gr.Image(type = "numpy", width = 320, height = 320, label = "Grad_CAM w.r.t dog"), gr.Textbox(label = 'Prediction', info = '[P of cat, P of dog]')],
157
- # description = "Visual Explanations from Deep Networks",
158
- # title = "Gradient-Weighted Class Activation Mapping (Grad-CAM)"
159
- # )
160
-
161
- with gr.Blocks() as demo:
162
- with gr.Row().style(equal_height=True):
163
- img_input = gr.Image(type = "pil", shape = (224,224), width = 320, height = 320)
164
- img_output1 = gr.Image(type = "numpy", width = 320, height = 320, label = "Grad_CAM w.r.t cat")
165
- img_output2 = gr.Image(type = "numpy", width = 320, height = 320, label = "Grad_CAM w.r.t dog")
166
-
167
  description = "Visual Explanations from Deep Networks",
168
  title = "Gradient-Weighted Class Activation Mapping (Grad-CAM)"
169
- img_input.upload(get_grad, inputs = img_input, outputs = [img_output1, img_output2])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
  demo.launch()
172
 
 
149
  text = "Raw Score: " + str(y_pred[0]) + "\nClassification: " + infer
150
  return grad_img_c, grad_img_d, text
151
 
152
+ demo = gr.Interface(
153
+ fn = get_grad,
154
+ with gr.Row():
155
+ inputs = gr.Image(type = "pil", shape = (224,224), width = 320, height = 320),
156
+ outputs = [gr.Image(type = "numpy", width = 320, height = 320, label = "Grad_CAM w.r.t cat"), gr.Image(type = "numpy", width = 320, height = 320, label = "Grad_CAM w.r.t dog"), gr.Textbox(label = 'Prediction', info = '[P of cat, P of dog]')],
 
 
 
 
 
 
 
 
 
 
157
  description = "Visual Explanations from Deep Networks",
158
  title = "Gradient-Weighted Class Activation Mapping (Grad-CAM)"
159
+ )
160
+
161
+ # with gr.Blocks() as demo:
162
+ # gr.Markdown(
163
+ # "# Gradient-Weighted Class Activation Mapping (Grad-CAM)\nVisual Explanations from Deep Networks"
164
+ # )
165
+
166
+ # with gr.Row().style(equal_height=True):
167
+ # img_input = gr.Image(type = "pil", shape = (224,224), width = 320, height = 320)
168
+ # img_output1 = gr.Image(type = "numpy", width = 320, height = 320, label = "Grad_CAM w.r.t cat")
169
+ # img_output2 = gr.Image(type = "numpy", width = 320, height = 320, label = "Grad_CAM w.r.t dog")
170
+
171
+ # description = "Visual Explanations from Deep Networks",
172
+ # title = "Gradient-Weighted Class Activation Mapping (Grad-CAM)"
173
+ # img_input.upload(get_grad, inputs = img_input, outputs = [img_output1, img_output2])
174
 
175
  demo.launch()
176