hussamalafandi commited on
Commit
9e5ed32
·
verified ·
1 Parent(s): 378eaf6

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ latent_space_interpolation.png filter=lfs diff=lfs merge=lfs -text
37
+ reconstruction_images_13_9c2c9b76dee391efede2.png filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Hussam Alafandi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ tags:
4
+ - vae
5
+ - celeba
6
+ - generative-model
7
+ - latent-space
8
+ - image-reconstruction
9
+ - attribute-manipulation
10
+ datasets:
11
+ - celeba
12
+ metrics:
13
+ - reconstruction-loss
14
+ - kl-divergence
15
+ license: mit
16
+ ---
17
+
18
+ # Variational Autoencoder (VAE) - CelebA Dataset
19
+
20
+ This repository contains a trained Variational Autoencoder (VAE) model on the CelebA dataset. The model is designed to encode and decode facial images, enabling tasks such as image reconstruction, latent space interpolation, and attribute manipulation.
21
+
22
+ ## Model Details
23
+
24
+ - **Architecture**: Variational Autoencoder (VAE)
25
+ - **Dataset**: CelebA
26
+ - **Latent Dimension**: 200
27
+ - **Training Subset Size**: 80,000 images
28
+ - **Batch Size**: 64
29
+ - **Learning Rate**: 1e-3
30
+ - **Epochs**: 10
31
+
32
+
33
+ ### Weights and Biases Run
34
+
35
+ The training process was tracked using [Weights and Biases](https://wandb.ai). You can view the full training logs and metrics [here](https://wandb.ai/hussam-alafandi/vae-celeba/runs/cv01woz1?nw=nwuserhussamalafandi).
36
+
37
+ ## Usage
38
+
39
+ ### Loading the Model
40
+
41
+ To load the trained model, use the following code snippet:
42
+ ```python
43
+ import torch
44
+ from vae_model import VAE # Ensure the VAE class is defined in vae_model.py
45
+
46
+ # Define the latent dimension
47
+ latent_dim = 200
48
+
49
+ # Initialize the model
50
+ model = VAE(latent_dim=latent_dim)
51
+
52
+ # Load the trained weights
53
+ model_path = "./vae_celeba_latent_200_epochs_10_batch_64_subset_80000.pth"
54
+ model.load_state_dict(torch.load(model_path))
55
+ model.eval()
56
+ ```
57
+
58
+ ### Applications
59
+
60
+ 1. **Image Reconstruction**: Reconstruct input images using the encoder and decoder.
61
+ 2. **Latent Space Interpolation**: Generate smooth transitions between two images by interpolating in the latent space.
62
+ 3. **Attribute Manipulation**: Modify specific attributes (e.g., smiling, hair color) by moving along attribute directions in the latent space.
63
+
64
+ ## Example Results
65
+
66
+ ### Reconstruction
67
+ Below is a reconstruction example where the first row represents the original images, and the second row represents the reconstructed images:
68
+
69
+ ![Reconstruction](./reconstruction_images_13_9c2c9b76dee391efede2.png)
70
+
71
+ ### Latent Space Interpolation
72
+ Below is an example of interpolating between two images in the latent space:
73
+
74
+ ![Latent Space Interpolation](./latent_space_interpolation.png)
75
+
76
+ ### Attribute Manipulation
77
+ Manipulating the "Smiling" attribute in the latent space:
78
+
79
+ ![Attribute Manipulation](./attribute_manipulation.png)
80
+
81
+
82
+ ## License
83
+
84
+ This project is licensed under the MIT License. See the LICENSE file for details.
attribute_manipulation.png ADDED
latent_space_interpolation.png ADDED

Git LFS Details

  • SHA256: 8955c86c9a1d33863b2bded806d0378829f2399d8d91fdc56fd9a0f28189341f
  • Pointer size: 131 Bytes
  • Size of remote file: 242 kB
reconstruction_images_13_9c2c9b76dee391efede2.png ADDED

Git LFS Details

  • SHA256: 9c2c9b76dee391efede2fe4ca6cf138f3e841c7199481e98bf16196199796c4e
  • Pointer size: 131 Bytes
  • Size of remote file: 391 kB
vae_celeba_latent_200_epochs_10_batch_64_subset_80000.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3229ca548c16939ff12f672470a3ff46418ff8defa5219bb545cc7dda1a1593c
3
+ size 15376564