jpterry commited on
Commit
e57a30b
·
1 Parent(s): 3c0eb5e

trying two figures

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -123,6 +123,8 @@ def predict_and_analyze(model_name, num_channels, dim, image):
123
 
124
  origin = 'lower'
125
 
 
 
126
  plt.rcParams['xtick.labelsize'] = ticks
127
  plt.rcParams['ytick.labelsize'] = ticks
128
 
@@ -148,9 +150,26 @@ def predict_and_analyze(model_name, num_channels, dim, image):
148
  ax1.set_title('Activation 1', fontsize=titles)
149
  ax2.set_title('Activation 2', fontsize=titles)
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  print("Sending to Hugging Face")
152
 
153
- return output, fig
154
 
155
 
156
  if __name__ == "__main__":
@@ -172,6 +191,7 @@ if __name__ == "__main__":
172
  gr.File(label="Input Data", show_label=True)],
173
  outputs=[gr.Textbox(lines=1, label="Prediction", show_label=True),
174
  # gr.Image(label="Input Image", show_label=True),
 
175
  # gr.Image(label="Activation 1", show_label=True),
176
  # gr.Image(label="Actication 2", show_label=True)],
177
  gr.Plot(label="Activations", show_label=True)
 
123
 
124
  origin = 'lower'
125
 
126
+
127
+ ##### Make the activation figure ######
128
  plt.rcParams['xtick.labelsize'] = ticks
129
  plt.rcParams['ytick.labelsize'] = ticks
130
 
 
150
  ax1.set_title('Activation 1', fontsize=titles)
151
  ax2.set_title('Activation 2', fontsize=titles)
152
 
153
+
154
+ ##### make the figure for the input image #####
155
+ plt.rcParams['xtick.labelsize'] = ticks
156
+ plt.rcParams['ytick.labelsize'] = ticks
157
+
158
+ input_fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(14, 12))
159
+
160
+
161
+ im0 = ax.imshow(input_image, cmap=cmap,
162
+ origin=origin)
163
+
164
+ divider = make_axes_locatable(ax)
165
+ cax = divider.append_axes('right', size='5%', pad=0.05)
166
+ fig.colorbar(im0, cax=cax, orientation='vertical')
167
+
168
+ ax.set_title('Input', fontsize=titles)
169
+
170
  print("Sending to Hugging Face")
171
 
172
+ return output, input_fig, fig
173
 
174
 
175
  if __name__ == "__main__":
 
191
  gr.File(label="Input Data", show_label=True)],
192
  outputs=[gr.Textbox(lines=1, label="Prediction", show_label=True),
193
  # gr.Image(label="Input Image", show_label=True),
194
+ gr.Plot(label="Input Image", show_label=True),
195
  # gr.Image(label="Activation 1", show_label=True),
196
  # gr.Image(label="Actication 2", show_label=True)],
197
  gr.Plot(label="Activations", show_label=True)