jpterry commited on
Commit
77ca615
·
1 Parent(s): 9f5f543

minor updates

Browse files
Files changed (1) hide show
  1. app.py +23 -17
app.py CHANGED
@@ -82,7 +82,26 @@ def get_activations(intermediate_model, image: list,
82
 
83
  return output, in_image, activation_1, activation_2
84
 
85
- def plot_activations(activation_1, activation_2, origin='lower'):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
 
88
  ##### Make the activation figure ######
@@ -161,6 +180,9 @@ def predict_and_analyze(model_name, num_channels, dim, image):
161
 
162
  origin = 'lower'
163
 
 
 
 
164
  # plot mean subtracted activations
165
  fig1 = plot_activations(activation_1, activation_2, origin=origin)
166
 
@@ -170,22 +192,6 @@ def predict_and_analyze(model_name, num_channels, dim, image):
170
  activation_2 = normalize_array(activation_2)
171
  fig2 = plot_activations(activation_1, activation_2, origin=origin)
172
 
173
-
174
- ##### make the figure for the input image #####
175
- plt.rcParams['xtick.labelsize'] = ticks
176
- plt.rcParams['ytick.labelsize'] = ticks
177
-
178
- input_fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(19, 8))
179
-
180
- im0 = ax.imshow(input_image, cmap=cmap,
181
- origin=origin)
182
-
183
- divider = make_axes_locatable(ax)
184
- cax = divider.append_axes('right', size='5%', pad=0.05)
185
- input_fig.colorbar(im0, cax=cax, orientation='vertical')
186
-
187
- ax.set_title('Input', fontsize=titles)
188
-
189
  print("Sending to Hugging Face")
190
 
191
  return output, input_fig, fig1, fig2
 
82
 
83
  return output, in_image, activation_1, activation_2
84
 
85
+ def plot_input(input_image: list, origin='lower'):
86
+
87
+ ##### make the figure for the input image #####
88
+ plt.rcParams['xtick.labelsize'] = ticks
89
+ plt.rcParams['ytick.labelsize'] = ticks
90
+
91
+ input_fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(19, 8))
92
+
93
+ im0 = ax.imshow(input_image, cmap=cmap,
94
+ origin=origin)
95
+
96
+ divider = make_axes_locatable(ax)
97
+ cax = divider.append_axes('right', size='5%', pad=0.05)
98
+ input_fig.colorbar(im0, cax=cax, orientation='vertical')
99
+
100
+ ax.set_title('Input', fontsize=titles)
101
+
102
+ return input_fig
103
+
104
+ def plot_activations(activation_1: list, activation_2: list, origin='lower'):
105
 
106
 
107
  ##### Make the activation figure ######
 
180
 
181
  origin = 'lower'
182
 
183
+ # plot input image
184
+ input_fig = plot_input(input_image, origin=origin)
185
+
186
  # plot mean subtracted activations
187
  fig1 = plot_activations(activation_1, activation_2, origin=origin)
188
 
 
192
  activation_2 = normalize_array(activation_2)
193
  fig2 = plot_activations(activation_1, activation_2, origin=origin)
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  print("Sending to Hugging Face")
196
 
197
  return output, input_fig, fig1, fig2