Skip to content
Snippets Groups Projects
Commit d0f5c607 authored by Sayyed Mahdyar Ravanbakhsh's avatar Sayyed Mahdyar Ravanbakhsh :coffee:
Browse files

Delete pix2pix.ipynb

parent e8f47071
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
<a href="https://colab.research.google.com/github/bkkaggle/pytorch-CycleGAN-and-pix2pix/blob/master/pix2pix.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
%% Cell type:markdown id: tags:
# Install
%% Cell type:code id: tags:
```
!git clone https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix
```
%% Cell type:code id: tags:
```
import os
os.chdir('pytorch-CycleGAN-and-pix2pix/')
```
%% Cell type:code id: tags:
```
!pip install -r requirements.txt
```
%% Cell type:markdown id: tags:
# Datasets
Download one of the official datasets with:
- `bash ./datasets/download_pix2pix_dataset.sh [cityscapes, night2day, edges2handbags, edges2shoes, facades, maps]`
Or use your own dataset by creating the appropriate folders and adding in the images. Follow the instructions [here](https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/docs/datasets.md#pix2pix-datasets).
%% Cell type:code id: tags:
```
!bash ./datasets/download_pix2pix_dataset.sh facades
```
%% Cell type:markdown id: tags:
# Pretrained models
Download one of the official pretrained models with:
- `bash ./scripts/download_pix2pix_model.sh [edges2shoes, sat2map, map2sat, facades_label2photo, and day2night]`
Or add your own pretrained model to `./checkpoints/{NAME}_pretrained/latest_net_G.pt`
%% Cell type:code id: tags:
```
!bash ./scripts/download_pix2pix_model.sh facades_label2photo
```
%% Cell type:markdown id: tags:
# Training
- `python train.py --dataroot ./datasets/facades --name facades_pix2pix --model pix2pix --direction BtoA`
Change the `--dataroot` and `--name` to your own dataset's path and model's name. Use `--gpu_ids 0,1,..` to train on multiple GPUs and `--batch_size` to change the batch size. Add `--direction BtoA` if you want to train a model to transfrom from class B to A.
%% Cell type:code id: tags:
```
!python train.py --dataroot ./datasets/facades --name facades_pix2pix --model pix2pix --direction BtoA
```
%% Cell type:markdown id: tags:
# Testing
- `python test.py --dataroot ./datasets/facades --direction BtoA --model pix2pix --name facades_pix2pix`
Change the `--dataroot`, `--name`, and `--direction` to be consistent with your trained model's configuration and how you want to transform images.
> from https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix:
> Note that we specified --direction BtoA as Facades dataset's A to B direction is photos to labels.
> If you would like to apply a pre-trained model to a collection of input images (rather than image pairs), please use --model test option. See ./scripts/test_single.sh for how to apply a model to Facade label maps (stored in the directory facades/testB).
> See a list of currently available models at ./scripts/download_pix2pix_model.sh
%% Cell type:code id: tags:
```
!ls checkpoints/
```
%% Cell type:code id: tags:
```
!python test.py --dataroot ./datasets/facades --direction BtoA --model pix2pix --name facades_label2photo_pretrained
```
%% Cell type:markdown id: tags:
# Visualize
%% Cell type:code id: tags:
```
import matplotlib.pyplot as plt
img = plt.imread('./results/facades_label2photo_pretrained/test_latest/images/100_fake_B.png')
plt.imshow(img)
```
%% Cell type:code id: tags:
```
img = plt.imread('./results/facades_label2photo_pretrained/test_latest/images/100_real_A.png')
plt.imshow(img)
```
%% Cell type:code id: tags:
```
img = plt.imread('./results/facades_label2photo_pretrained/test_latest/images/100_real_B.png')
plt.imshow(img)
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment