Path: blob/master/notebooks/book2/28/mix_ppca_celebA.ipynb
1192 views
Kernel: Python 3 (ipykernel)
Get the CelebA dataset
In [1]:
Get helpers
In [27]:
In [25]:
Out[25]:
/content
In [28]:
Out[28]:
data.py kaggle.json mfa_celeba_helpers.py models __pycache__ sample_data
Get the Kaggle api token and upload it to colab. Follow the instructions here.
In [3]:
In [7]:
Out[7]:
Saving kaggle.json to kaggle.json
In [8]:
Out[8]:
mkdir: cannot create directory ‘/root/.kaggle’: File exists
In [9]:
In [10]:
Getting the checkpoint of the model from buckets.
In [14]:
In [11]:
In [12]:
In [15]:
Out[15]:
Copying gs://probml_data/mix_PPCA/model_c_300_l_10_init_rnd_samples.pth...
/ [1 files][168.8 MiB/168.8 MiB]
Operation completed over 1 objects/168.8 MiB.
Main
In [29]:
Inference
Preparing dataset
In [30]:
Out[30]:
Preparing dataset and parameters for celeba ...
Downloading dataset. Please while while the download and extraction processes complete
Downloading celeba-dataset.zip to ./data
100%|██████████| 1.33G/1.33G [00:07<00:00, 186MB/s]
Downloading list_attr_celeba.csv.zip to ./data
100%|██████████| 2.02M/2.02M [00:00<00:00, 197MB/s]
Downloading list_bbox_celeba.csv.zip to ./data
100%|██████████| 1.54M/1.54M [00:00<00:00, 229MB/s]
Downloading list_eval_partition.csv.zip to ./data
100%|██████████| 466k/466k [00:00<00:00, 122MB/s]
Downloading list_landmarks_align_celeba.csv.zip to ./data
100%|██████████| 2.07M/2.07M [00:00<00:00, 232MB/s]
Done!
/content/data.py:70: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor').
self.attr = (self.attr + 1) // 2 # map from {-1, 1} to {0, 1}
In [31]:
Loading pre-trained MFA model
In [32]:
Out[32]:
Loading pre-trained MFA model...
<All keys matched successfully>
Samples
In [39]:
In [40]:
Out[40]:
WARNING:imageio:Lossy conversion from float64 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
Visualizing the trained model...
In [41]:
Out[41]:
Generating random samples...
WARNING:imageio:Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
Showing outliers
In [ ]:
Enter gird size: 1 4
In [42]:
Out[42]:
/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:566: UserWarning: This DataLoader will create 8 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
cpuset_checked))
Finding dataset outliers...
100%|██████████| 156/156 [00:31<00:00, 4.91it/s]
WARNING:imageio:Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
Reconstructing original masked images
In [43]:
In [44]:
Out[44]:
WARNING:imageio:Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
Reconstructing images from the trained model...
WARNING:imageio:Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.