jpterry commited on
Commit
9c50a2c
·
1 Parent(s): 3cf0e0f

putting everything on the same plot

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -117,7 +117,7 @@ def predict_and_analyze(model_name, num_channels, dim, image):
117
  activation_2 = normalize_array(activation_2)
118
 
119
  # convert input image to RGB
120
- input_image = Image.fromarray(np.uint8(cm.magma(input_image)*255))
121
 
122
  print("Plotting")
123
 
@@ -126,28 +126,31 @@ def predict_and_analyze(model_name, num_channels, dim, image):
126
  plt.rcParams['xtick.labelsize'] = ticks
127
  plt.rcParams['ytick.labelsize'] = ticks
128
 
129
- fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(19, 8))
130
 
131
- ax1, ax2 = axs[0], axs[1]
132
 
 
 
133
  im1 = ax1.imshow(activation_1, cmap=cmap,
134
  origin=origin)
135
  im2 = ax2.imshow(activation_2, cmap=cmap,
136
  origin=origin)
137
 
138
- ims = [im1, im2]
139
 
140
  for (i, ax) in enumerate(axs):
141
  divider = make_axes_locatable(ax)
142
  cax = divider.append_axes('right', size='5%', pad=0.05)
143
  fig.colorbar(ims[i], cax=cax, orientation='vertical')
144
 
 
145
  ax1.set_title('First Activation', fontsize=titles)
146
  ax2.set_title('Second Activation', fontsize=titles)
147
 
148
  print("Sending to Hugging Face")
149
 
150
- return output, input_image, fig
151
 
152
 
153
  if __name__ == "__main__":
@@ -168,7 +171,7 @@ if __name__ == "__main__":
168
  show_label=True),
169
  gr.File(label="Input Data", show_label=True)],
170
  outputs=[gr.Textbox(lines=1, label="Prediction", show_label=True),
171
- gr.Image(label="Input Image", show_label=True),
172
  # gr.Image(label="Activation 1", show_label=True),
173
  # gr.Image(label="Actication 2", show_label=True)],
174
  gr.Plot(label="Activations", show_label=True)
 
117
  activation_2 = normalize_array(activation_2)
118
 
119
  # convert input image to RGB
120
+ input_pil_image = Image.fromarray(np.uint8(cm.magma(input_image)*255))
121
 
122
  print("Plotting")
123
 
 
126
  plt.rcParams['xtick.labelsize'] = ticks
127
  plt.rcParams['ytick.labelsize'] = ticks
128
 
129
+ fig, axs = plt.subplots(nrows=3, ncols=1, figsize=(8, 28))
130
 
131
+ ax0, ax1, ax2 = axs[0], axs[1], axs[2]
132
 
133
+ im0 = ax1.imshow(input_image, cmap=cmap,
134
+ origin=origin)
135
  im1 = ax1.imshow(activation_1, cmap=cmap,
136
  origin=origin)
137
  im2 = ax2.imshow(activation_2, cmap=cmap,
138
  origin=origin)
139
 
140
+ ims = [im0, im1, im2]
141
 
142
  for (i, ax) in enumerate(axs):
143
  divider = make_axes_locatable(ax)
144
  cax = divider.append_axes('right', size='5%', pad=0.05)
145
  fig.colorbar(ims[i], cax=cax, orientation='vertical')
146
 
147
+ ax0.set_title('Input', fontsize=titles)
148
  ax1.set_title('First Activation', fontsize=titles)
149
  ax2.set_title('Second Activation', fontsize=titles)
150
 
151
  print("Sending to Hugging Face")
152
 
153
+ return output, input_pil_image, fig
154
 
155
 
156
  if __name__ == "__main__":
 
171
  show_label=True),
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)