marta-marta commited on
Commit
878d5d1
·
1 Parent(s): 8ce1c5e

Modifying the figures to be published

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py CHANGED
@@ -320,6 +320,7 @@ latent_matrix = np.array(latent_matrix).T # Transposes the matrix so that each
320
  # Plotting the Interpolation in 2D Using Chosen Points
321
  if st.button("Generate Interpolation:"):
322
  plt.figure(2)
 
323
  plot_rows = 2
324
  plot_columns = num_interp + 2
325
 
@@ -340,5 +341,46 @@ if st.button("Generate Interpolation:"):
340
  plt.subplot(plot_rows, plot_columns, num_interp + 2), plt.imshow(number_2, cmap='gray', vmin=0, vmax=1)
341
  # plt.title("Second Interpolation Point:\n" + str(box_shape_test[number_2]) + "\nPixel Density: " + str(
342
  # box_density_test[number_2]) + "\nAdditional Pixels: " + str(additional_pixels_test[number_2])) # + "\nPredicted Latent Point 2: " + str(latent_point_2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
  plt.figure(2)
344
  st.pyplot(plt.figure(2))
 
320
  # Plotting the Interpolation in 2D Using Chosen Points
321
  if st.button("Generate Interpolation:"):
322
  plt.figure(2)
323
+ """
324
  plot_rows = 2
325
  plot_columns = num_interp + 2
326
 
 
341
  plt.subplot(plot_rows, plot_columns, num_interp + 2), plt.imshow(number_2, cmap='gray', vmin=0, vmax=1)
342
  # plt.title("Second Interpolation Point:\n" + str(box_shape_test[number_2]) + "\nPixel Density: " + str(
343
  # box_density_test[number_2]) + "\nAdditional Pixels: " + str(additional_pixels_test[number_2])) # + "\nPredicted Latent Point 2: " + str(latent_point_2)
344
+ """
345
+ linear_interp_latent = np.linspace(latent_point_1, latent_point_2, interp_length)
346
+ print(len(linear_interp_latent))
347
+
348
+ linear_predicted_interps = []
349
+ figure = np.zeros((28 * num_interp, 28))
350
+ for i in range(num_interp):
351
+ generated_image = decoder_model_boxes.predict(np.array([linear_interp_latent[i]]))[0]
352
+ figure[i * 28:(i + 1) * 28, 0:28, ] = generated_image[:, :, -1]
353
+ linear_predicted_interps.append(generated_image[:, :, -1])
354
+
355
+ plt.figure(figsize=(15, 15))
356
+ plt.imshow(figure, cmap='gray')
357
+
358
+ '''
359
+ latent_matrix_2 = [] # This will contain the latent points of the interpolation
360
+ for column in range(latent_dimensionality):
361
+ new_column = np.linspace(latent_point_3[column], latent_point_4[column], num_interp)
362
+ latent_matrix_2.append(new_column)
363
+ latent_matrix_2 = np.array(latent_matrix_2).T # Transposes the matrix so that each row can be easily indexed
364
+
365
+ mesh = [] # This will create a mesh by interpolating between the two interpolations
366
+ for column in range(num_interp):
367
+ row = np.linspace(latent_matrix[column], latent_matrix_2[column], num_interp)
368
+ mesh.append(row)
369
+
370
+ mesh = np.transpose(mesh, axes=(1, 0, 2)) # Transpose the array so it matches the original interpolation
371
+ generator_model = decoder_model_boxes
372
+
373
+ figure = np.zeros((28 * num_interp, 28 * num_interp))
374
+
375
+ mesh_predicted_interps = []
376
+ for i in range(num_interp):
377
+ for j in range(num_interp):
378
+ generated_image = generator_model.predict(np.array([mesh[i][j]]))[0]
379
+ figure[i * 28:(i + 1) * 28, j * 28:(j + 1) * 28, ] = generated_image[:, :, -1]
380
+ mesh_predicted_interps.append(generated_image[:, :, -1])
381
+
382
+ plt.figure(figsize=(15, 15))
383
+ plt.imshow(figure, cmap='gray')
384
+ '''
385
  plt.figure(2)
386
  st.pyplot(plt.figure(2))