Skip to content
Snippets Groups Projects
Commit f2158c7a authored by Julien Dejasmin's avatar Julien Dejasmin
Browse files

visualization reconstructions

parent a21ee080
No related branches found
No related tags found
No related merge requests found
Showing
with 25 additions and 38 deletions
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.7" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.8 (Pytorch_CNN_mixt_representation)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="PyDocumentationSettings"> <component name="PyDocumentationSettings">
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
<component name="JavaScriptSettings"> <component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" /> <option name="languageLevel" value="ES6" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (Pytorch_CNN_mixt_representation)" project-jdk-type="Python SDK" />
</project> </project>
\ No newline at end of file
...@@ -8,44 +8,31 @@ import torch ...@@ -8,44 +8,31 @@ import torch
def viz_reconstruction(model, path, expe_name, batch): def viz_reconstruction(model, path, expe_name, batch):
<<<<<<< HEAD
=======
>>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3
file_path = os.path.join(path, expe_name, 'checkpoints', 'last') file_path = os.path.join(path, expe_name, 'checkpoints', 'last')
checkpoint = torch.load(file_path, map_location=torch.device('cpu')) checkpoint = torch.load(file_path, map_location=torch.device('cpu'))
model.load_state_dict(checkpoint['model_states']['model']) model.load_state_dict(checkpoint['model_states']['model'])
nb_epochs = checkpoint['iter']
viz_chairs = Viz(model) viz_chairs = Viz(model)
viz_chairs.save_images = False viz_chairs.save_images = False
recon_grid, _ = viz_chairs.reconstructions(batch, size=(8, 8)) recon_grid, _ = viz_chairs.reconstructions(batch, size=(8, 8))
fig = plt.figure(figsize=(10, 10)) plt.figure(figsize=(10, 10))
recon_grid = recon_grid.permute(1, 2, 0) recon_grid = recon_grid.permute(1, 2, 0)
<<<<<<< HEAD plt.title('model: {}, nb_epochs trained: {}'.format(expe_name, nb_epochs))
plt.title(expe_name)
=======
>>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3
plt.imshow(recon_grid.numpy()) plt.imshow(recon_grid.numpy())
plt.savefig('../reconstruction_im/charis_' + expe_name + '.png') plt.savefig('../reconstruction_im/charis_' + expe_name + '.png')
plt.show() plt.show()
<<<<<<< HEAD
def plot_loss(expe_name=None, path=None, save=False):
=======
def plot_loss(expe_name=None, save=False, path=None): def plot_loss(expe_name=None, save=False, path=None):
>>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3
file_path = os.path.join(path, expe_name, 'checkpoints', 'last') file_path = os.path.join(path, expe_name, 'checkpoints', 'last')
checkpoint = torch.load(file_path, map_location=torch.device('cpu')) checkpoint = torch.load(file_path, map_location=torch.device('cpu'))
losses = checkpoint['loss'] losses = checkpoint['loss']
title = 'losses model:' + expe_name title = 'losses model:' + expe_name
<<<<<<< HEAD
plt.title(title) plt.title(title)
=======
>>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3
plt.plot(losses) plt.plot(losses)
plt.xlabel('Epochs') plt.xlabel('Epochs')
plt.ylabel('loss') plt.ylabel('loss')
...@@ -64,7 +51,6 @@ _, dataloader_chairs = get_chairs_dataloader(batch_size=32) ...@@ -64,7 +51,6 @@ _, dataloader_chairs = get_chairs_dataloader(batch_size=32)
for batch_chairs, labels_chairs in dataloader_chairs: for batch_chairs, labels_chairs in dataloader_chairs:
break break
# torch.load('data/batch_chairs.pt')
path_to_model_folder_chairs = '../trained_models/rendered_chairs/' path_to_model_folder_chairs = '../trained_models/rendered_chairs/'
list_expe = ['VAE_bs_64', 'VAE_bs_256', 'beta_VAE_bs_64', 'beta_VAE_bs_256', 'VAE_bs_64_ls_10_lr_1e_3', list_expe = ['VAE_bs_64', 'VAE_bs_256', 'beta_VAE_bs_64', 'beta_VAE_bs_256', 'VAE_bs_64_ls_10_lr_1e_3',
...@@ -73,22 +59,20 @@ list_expe = ['VAE_bs_64', 'VAE_bs_256', 'beta_VAE_bs_64', 'beta_VAE_bs_256', 'VA ...@@ -73,22 +59,20 @@ list_expe = ['VAE_bs_64', 'VAE_bs_256', 'beta_VAE_bs_64', 'beta_VAE_bs_256', 'VA
list_expe_ls_5 = ['VAE_bs_64_ls_5', 'beta_VAE_bs_64_ls_5'] list_expe_ls_5 = ['VAE_bs_64_ls_5', 'beta_VAE_bs_64_ls_5']
list_expe_ls_15 = ['VAE_bs_64_ls_15', 'beta_VAE_bs_64_ls_15'] list_expe_ls_15 = ['VAE_bs_64_ls_15', 'beta_VAE_bs_64_ls_15']
list_expe_ls_20 = ['VAE_bs_64_ls_20', 'beta_VAE_bs_64_ls_20'] list_expe_ls_20 = ['VAE_bs_64_ls_20', 'beta_VAE_bs_64_ls_20']
list_expe_ls_30 = ['VAE_bs_64_ls_30']
list_expe_ls_40 = ['VAE_bs_64_ls_40']
list_expe_ls_50 = ['VAE_bs_64_ls_50']
<<<<<<< HEAD
list_expe_ls_10_64_64_128_128 = ['VAE_bs_64_conv_64_64_128_128'] list_expe_ls_10_64_64_128_128 = ['VAE_bs_64_conv_64_64_128_128']
list_expe_ls_10_128_128_256_256 = ['VAE_bs_64_conv_128_128_256_256']
img_size = (3, 64, 64) img_size = (3, 64, 64)
path = '../trained_models/rendered_chairs' path = '../trained_models/rendered_chairs'
"""
for i in list_expe_ls_5: for i in list_expe_ls_5:
plot_loss(i, path=path) plot_loss(i, path=path)
""" """
=======
img_size = (3, 64, 64)
>>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3
latent_spec = {"cont": 10} latent_spec = {"cont": 10}
model = VAE(img_size, latent_spec=latent_spec) model = VAE(img_size, latent_spec=latent_spec)
for i in list_expe: for i in list_expe:
...@@ -108,18 +92,24 @@ latent_spec = {"cont": 20} ...@@ -108,18 +92,24 @@ latent_spec = {"cont": 20}
model = VAE(img_size, latent_spec=latent_spec) model = VAE(img_size, latent_spec=latent_spec)
for i in list_expe_ls_20: for i in list_expe_ls_20:
viz_reconstruction(model, path_to_model_folder_chairs, i, batch_chairs) viz_reconstruction(model, path_to_model_folder_chairs, i, batch_chairs)
<<<<<<< HEAD
latent_spec = {"cont": 30}
model = VAE(img_size, latent_spec=latent_spec)
for i in list_expe_ls_30:
viz_reconstruction(model, path_to_model_folder_chairs, i, batch_chairs)
latent_spec = {"cont": 40}
model = VAE(img_size, latent_spec=latent_spec)
for i in list_expe_ls_40:
viz_reconstruction(model, path_to_model_folder_chairs, i, batch_chairs)
latent_spec = {"cont": 50}
model = VAE(img_size, latent_spec=latent_spec)
for i in list_expe_ls_50:
viz_reconstruction(model, path_to_model_folder_chairs, i, batch_chairs)
latent_spec = {"cont": 10} latent_spec = {"cont": 10}
model = VAE(img_size, latent_spec=latent_spec, nb_filter_conv1=64, nb_filter_conv2=64, nb_filter_conv3=128, model = VAE(img_size, latent_spec=latent_spec, nb_filter_conv1=64, nb_filter_conv2=64, nb_filter_conv3=128,
nb_filter_conv4=128) nb_filter_conv4=128)
for i in list_expe_ls_10_64_64_128_128: for i in list_expe_ls_10_64_64_128_128:
viz_reconstruction(model, path_to_model_folder_chairs, i, batch_chairs) viz_reconstruction(model, path_to_model_folder_chairs, i, batch_chairs)
model = VAE(img_size, latent_spec=latent_spec, nb_filter_conv1=128, nb_filter_conv2=128, nb_filter_conv3=256,
nb_filter_conv4=256)
for i in list_expe_ls_10_128_128_256_256:
viz_reconstruction(model, path_to_model_folder_chairs, i, batch_chairs)
"""
=======
>>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3
...@@ -77,10 +77,7 @@ def main(args): ...@@ -77,10 +77,7 @@ def main(args):
# Define trainer # Define trainer
trainer = Trainer(model, device, optimizer, criterion, save_step=args.save_step, ckpt_dir=args.ckpt_dir, trainer = Trainer(model, device, optimizer, criterion, save_step=args.save_step, ckpt_dir=args.ckpt_dir,
<<<<<<< HEAD
load_model_checkpoint=args.load_model_checkpoint, load_model_checkpoint=args.load_model_checkpoint,
=======
>>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3
ckpt_name=args.ckpt_name, ckpt_name=args.ckpt_name,
expe_name=args.experiment_name, expe_name=args.experiment_name,
dataset=args.dataset, dataset=args.dataset,
......
reconstruction_im/charis_VAE_bs_256.png

129 KiB | W: | H:

reconstruction_im/charis_VAE_bs_256.png

196 KiB | W: | H:

reconstruction_im/charis_VAE_bs_256.png
reconstruction_im/charis_VAE_bs_256.png
reconstruction_im/charis_VAE_bs_256.png
reconstruction_im/charis_VAE_bs_256.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_VAE_bs_64.png

114 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64.png

183 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64.png
reconstruction_im/charis_VAE_bs_64.png
reconstruction_im/charis_VAE_bs_64.png
reconstruction_im/charis_VAE_bs_64.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_VAE_bs_64_conv_64_64_128_128.png

200 KiB

reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png

61.3 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png

102 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png
reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png
reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png
reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png

115 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png

190 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png
reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png
reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png
reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_VAE_bs_64_ls_15.png

120 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_15.png

192 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_15.png
reconstruction_im/charis_VAE_bs_64_ls_15.png
reconstruction_im/charis_VAE_bs_64_ls_15.png
reconstruction_im/charis_VAE_bs_64_ls_15.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_VAE_bs_64_ls_20.png

114 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_20.png

190 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_20.png
reconstruction_im/charis_VAE_bs_64_ls_20.png
reconstruction_im/charis_VAE_bs_64_ls_20.png
reconstruction_im/charis_VAE_bs_64_ls_20.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_VAE_bs_64_ls_30.png

194 KiB

reconstruction_im/charis_VAE_bs_64_ls_40.png

187 KiB

reconstruction_im/charis_VAE_bs_64_ls_5.png

114 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_5.png

183 KiB | W: | H:

reconstruction_im/charis_VAE_bs_64_ls_5.png
reconstruction_im/charis_VAE_bs_64_ls_5.png
reconstruction_im/charis_VAE_bs_64_ls_5.png
reconstruction_im/charis_VAE_bs_64_ls_5.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_VAE_bs_64_ls_50.png

192 KiB

reconstruction_im/charis_beta_VAE_bs_256.png

121 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_256.png

193 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_256.png
reconstruction_im/charis_beta_VAE_bs_256.png
reconstruction_im/charis_beta_VAE_bs_256.png
reconstruction_im/charis_beta_VAE_bs_256.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_beta_VAE_bs_64.png

119 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_64.png

189 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_64.png
reconstruction_im/charis_beta_VAE_bs_64.png
reconstruction_im/charis_beta_VAE_bs_64.png
reconstruction_im/charis_beta_VAE_bs_64.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_beta_VAE_bs_64_ls_15.png

113 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_64_ls_15.png

186 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_64_ls_15.png
reconstruction_im/charis_beta_VAE_bs_64_ls_15.png
reconstruction_im/charis_beta_VAE_bs_64_ls_15.png
reconstruction_im/charis_beta_VAE_bs_64_ls_15.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_beta_VAE_bs_64_ls_20.png

121 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_64_ls_20.png

193 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_64_ls_20.png
reconstruction_im/charis_beta_VAE_bs_64_ls_20.png
reconstruction_im/charis_beta_VAE_bs_64_ls_20.png
reconstruction_im/charis_beta_VAE_bs_64_ls_20.png
  • 2-up
  • Swipe
  • Onion skin
reconstruction_im/charis_beta_VAE_bs_64_ls_5.png

117 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_64_ls_5.png

188 KiB | W: | H:

reconstruction_im/charis_beta_VAE_bs_64_ls_5.png
reconstruction_im/charis_beta_VAE_bs_64_ls_5.png
reconstruction_im/charis_beta_VAE_bs_64_ls_5.png
reconstruction_im/charis_beta_VAE_bs_64_ls_5.png
  • 2-up
  • Swipe
  • Onion skin
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment