diff --git a/.idea/Pytorch_CNN_mixt_representation.iml b/.idea/Pytorch_CNN_mixt_representation.iml index 1f1ea62e76c8be2f7c6ab76df39f8f9c33f17a17..1a230f82cba8f291c413aa7d0b56fa62fa47bd00 100644 --- a/.idea/Pytorch_CNN_mixt_representation.iml +++ b/.idea/Pytorch_CNN_mixt_representation.iml @@ -2,7 +2,7 @@ <module type="PYTHON_MODULE" version="4"> <component name="NewModuleRootManager"> <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" /> </component> <component name="PyDocumentationSettings"> diff --git a/.idea/misc.xml b/.idea/misc.xml index 865611434f0cce78ec2223c6c4d52a717e8ec1c1..f70beb9a0414cc9d693a5feea2b56fde1243dcbc 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ <component name="JavaScriptSettings"> <option name="languageLevel" value="ES6" /> </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> \ No newline at end of file diff --git a/Experiments/experiments.py b/Experiments/experiments.py index c45376e6a6a18366b73470bb06f23fd66d37db8a..4e9eb237cd61da7430ed8fc77ba1956b1150b2b2 100644 --- a/Experiments/experiments.py +++ b/Experiments/experiments.py @@ -8,44 +8,31 @@ import torch def viz_reconstruction(model, path, expe_name, batch): -<<<<<<< HEAD -======= - ->>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3 file_path = os.path.join(path, expe_name, 'checkpoints', 'last') checkpoint = torch.load(file_path, map_location=torch.device('cpu')) model.load_state_dict(checkpoint['model_states']['model']) + nb_epochs = checkpoint['iter'] viz_chairs = Viz(model) viz_chairs.save_images = False 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) -<<<<<<< HEAD - plt.title(expe_name) -======= ->>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3 + plt.title('model: {}, nb_epochs trained: {}'.format(expe_name, nb_epochs)) plt.imshow(recon_grid.numpy()) plt.savefig('../reconstruction_im/charis_' + expe_name + '.png') plt.show() -<<<<<<< HEAD -def plot_loss(expe_name=None, path=None, save=False): -======= def plot_loss(expe_name=None, save=False, path=None): ->>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3 file_path = os.path.join(path, expe_name, 'checkpoints', 'last') checkpoint = torch.load(file_path, map_location=torch.device('cpu')) losses = checkpoint['loss'] title = 'losses model:' + expe_name -<<<<<<< HEAD plt.title(title) -======= ->>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3 plt.plot(losses) plt.xlabel('Epochs') plt.ylabel('loss') @@ -64,7 +51,6 @@ _, dataloader_chairs = get_chairs_dataloader(batch_size=32) for batch_chairs, labels_chairs in dataloader_chairs: break -# torch.load('data/batch_chairs.pt') 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', @@ -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_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_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_128_128_256_256 = ['VAE_bs_64_conv_128_128_256_256'] img_size = (3, 64, 64) - path = '../trained_models/rendered_chairs' + +""" for i in list_expe_ls_5: plot_loss(i, path=path) - """ -======= -img_size = (3, 64, 64) ->>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3 latent_spec = {"cont": 10} model = VAE(img_size, latent_spec=latent_spec) for i in list_expe: @@ -108,18 +92,24 @@ latent_spec = {"cont": 20} model = VAE(img_size, latent_spec=latent_spec) for i in list_expe_ls_20: 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} model = VAE(img_size, latent_spec=latent_spec, nb_filter_conv1=64, nb_filter_conv2=64, nb_filter_conv3=128, nb_filter_conv4=128) for i in list_expe_ls_10_64_64_128_128: 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 diff --git a/main.py b/main.py index 5b373424763c5794025c1b8faeeedaabe8386cbb..9f3bcc8017cc0783ffb48112e32cb77cbb457960 100644 --- a/main.py +++ b/main.py @@ -77,10 +77,7 @@ def main(args): # Define trainer trainer = Trainer(model, device, optimizer, criterion, save_step=args.save_step, ckpt_dir=args.ckpt_dir, -<<<<<<< HEAD load_model_checkpoint=args.load_model_checkpoint, -======= ->>>>>>> 0c34b372fa08007c42e406c24e2b23ddea1753b3 ckpt_name=args.ckpt_name, expe_name=args.experiment_name, dataset=args.dataset, diff --git a/reconstruction_im/charis_VAE_bs_256.png b/reconstruction_im/charis_VAE_bs_256.png index 23e3483fbc43a336c33d7966e348d7f565292764..bff1fcde28087cc51585bc28b1275d9363135cb8 100644 Binary files a/reconstruction_im/charis_VAE_bs_256.png and b/reconstruction_im/charis_VAE_bs_256.png differ diff --git a/reconstruction_im/charis_VAE_bs_64.png b/reconstruction_im/charis_VAE_bs_64.png index be31beb80d616d43f109ce6c1711e11b751ed75a..98cfca4520d226bc7aaf53ce7dcd1b8deaed3200 100644 Binary files a/reconstruction_im/charis_VAE_bs_64.png and b/reconstruction_im/charis_VAE_bs_64.png differ diff --git a/reconstruction_im/charis_VAE_bs_64_conv_64_64_128_128.png b/reconstruction_im/charis_VAE_bs_64_conv_64_64_128_128.png new file mode 100644 index 0000000000000000000000000000000000000000..928ef1498f0ad1286cc3d9139aebc553f7139607 Binary files /dev/null and b/reconstruction_im/charis_VAE_bs_64_conv_64_64_128_128.png differ diff --git a/reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png b/reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png index 1035b600f905bbcd684efa4ab7298a9002d52b5c..a594af5ec3aeb327659ddcea73e6afa167ecbb41 100644 Binary files a/reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png and b/reconstruction_im/charis_VAE_bs_64_ls_10_lr_1e_3.png differ diff --git a/reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png b/reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png index 6fc66f2f47731558316f8795e691eb8418841a53..c61be0bfd10db4861e278648b6f5ebed05096bf7 100644 Binary files a/reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png and b/reconstruction_im/charis_VAE_bs_64_ls_10_lr_5e_4.png differ diff --git a/reconstruction_im/charis_VAE_bs_64_ls_15.png b/reconstruction_im/charis_VAE_bs_64_ls_15.png index 6da0b5f5450a2c0385aace15464b1773a5835075..5f33c6b9c5836971057647b29e3decce09e5ddc1 100644 Binary files a/reconstruction_im/charis_VAE_bs_64_ls_15.png and b/reconstruction_im/charis_VAE_bs_64_ls_15.png differ diff --git a/reconstruction_im/charis_VAE_bs_64_ls_20.png b/reconstruction_im/charis_VAE_bs_64_ls_20.png index 75b85cb51c300b4027d43e0ff391c2cc68445690..aa5e9b6836ff7fbdfecd3cec43ab146b9b57e923 100644 Binary files a/reconstruction_im/charis_VAE_bs_64_ls_20.png and b/reconstruction_im/charis_VAE_bs_64_ls_20.png differ diff --git a/reconstruction_im/charis_VAE_bs_64_ls_30.png b/reconstruction_im/charis_VAE_bs_64_ls_30.png new file mode 100644 index 0000000000000000000000000000000000000000..c3cc443474dce18e6f39000582bb21b336f4145b Binary files /dev/null and b/reconstruction_im/charis_VAE_bs_64_ls_30.png differ diff --git a/reconstruction_im/charis_VAE_bs_64_ls_40.png b/reconstruction_im/charis_VAE_bs_64_ls_40.png new file mode 100644 index 0000000000000000000000000000000000000000..1670cc17ff041e80530234a2d16550126553ed2b Binary files /dev/null and b/reconstruction_im/charis_VAE_bs_64_ls_40.png differ diff --git a/reconstruction_im/charis_VAE_bs_64_ls_5.png b/reconstruction_im/charis_VAE_bs_64_ls_5.png index bb5d36d5a242430d88307a292acf6f4e00d32359..fc72e48d732b55f48489ce3f98b98fb13bac37e2 100644 Binary files a/reconstruction_im/charis_VAE_bs_64_ls_5.png and b/reconstruction_im/charis_VAE_bs_64_ls_5.png differ diff --git a/reconstruction_im/charis_VAE_bs_64_ls_50.png b/reconstruction_im/charis_VAE_bs_64_ls_50.png new file mode 100644 index 0000000000000000000000000000000000000000..8df74064debbace997044af694d3c3bf9e8db5f8 Binary files /dev/null and b/reconstruction_im/charis_VAE_bs_64_ls_50.png differ diff --git a/reconstruction_im/charis_beta_VAE_bs_256.png b/reconstruction_im/charis_beta_VAE_bs_256.png index 0b4bc5b9529c16c0b345d137cffb64b70cf3dcc5..16c26edfb3756b6b93865b38a9d70cfdd9feadf1 100644 Binary files a/reconstruction_im/charis_beta_VAE_bs_256.png and b/reconstruction_im/charis_beta_VAE_bs_256.png differ diff --git a/reconstruction_im/charis_beta_VAE_bs_64.png b/reconstruction_im/charis_beta_VAE_bs_64.png index 5100b2b17f720a661715ffbc1a4bf7501fda73bc..1be82dbc9602fc54f3597e1cb1a41a434b463543 100644 Binary files a/reconstruction_im/charis_beta_VAE_bs_64.png and b/reconstruction_im/charis_beta_VAE_bs_64.png differ diff --git a/reconstruction_im/charis_beta_VAE_bs_64_ls_15.png b/reconstruction_im/charis_beta_VAE_bs_64_ls_15.png index c7cc462ee8c9fb52b0645b250f7cddfb79556ef8..dc336d17e847bd06ff3457de07184e0033ed146c 100644 Binary files a/reconstruction_im/charis_beta_VAE_bs_64_ls_15.png and b/reconstruction_im/charis_beta_VAE_bs_64_ls_15.png differ diff --git a/reconstruction_im/charis_beta_VAE_bs_64_ls_20.png b/reconstruction_im/charis_beta_VAE_bs_64_ls_20.png index 9a00a3657cd09a41c51c4ac4f7ada961e5870018..9291127082ea077774fa8db336c881fa98d4ac26 100644 Binary files a/reconstruction_im/charis_beta_VAE_bs_64_ls_20.png and b/reconstruction_im/charis_beta_VAE_bs_64_ls_20.png differ diff --git a/reconstruction_im/charis_beta_VAE_bs_64_ls_5.png b/reconstruction_im/charis_beta_VAE_bs_64_ls_5.png index 14368c68c25a3c524b19dce52c86f3ba6be114c0..2f8022ded1ab3364ac3c8bfc356d29045aaf6706 100644 Binary files a/reconstruction_im/charis_beta_VAE_bs_64_ls_5.png and b/reconstruction_im/charis_beta_VAE_bs_64_ls_5.png differ