Permalink
Browse files

Update USAGE

  • Loading branch information...
Ming-Yu Liu
Ming-Yu Liu committed Oct 4, 2017
1 parent 2556375 commit 42a87622bf31d241a1966fc8c52140c4ceadd1f0
View
109 USAGE.md
@@ -25,81 +25,58 @@ conda install -c menpo opencv=2.4.11
pip install tensorboard
```
### Usage
### Example Usage
The scripts are based on our experiments on the [CelebA dataset](http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html).
#### Training
```
python train.py --config ../exps/celeba_blond_hair.yaml --log ../logs;
```
#### Resume training
```
python train.py --config ../exps/celeba_blond_hair.yaml --log ../logs --resume 1;
```
#### Testing
We thank Ian Goodfellow for kindly providing his photo for our demo.
Download pretrained models from https://drive.google.com/drive/folders/0BwpOatrZwxK6STdZcXNNcXpFSHM?usp=sharing and save them in snapshots/ folder.
From no-blond-hair to blond-hair. (Turn blond hair attribute on)
```
./translate_one_image.py --config ../exps/celeba_blond_hair.yaml --image_name ../images/ian.jpg --output_image_name ../results/ian_to_blond_hair.jpg --weights ../snapshots/celeba_blond_hair_gen_00500000.pkl --a2b 0
```
![No-blond-hair to blond-hair](./results/ian_to_blond_hair.jpg)
From goatee to non-goatee. (Turn goatee attribute off)
```
./translate_one_image.py --config ../exps/celeba_blond_hair.yaml --image_name ../images/ian.jpg --output_image_name ../results/ian_to_no_goatee.jpg --weights ../snapshots/celeba_goatee_gen_00500000.pkl --a2b 1
```
![Goatee to non-goatee](./results/ian_to_no_goatee.jpg)
From no eyeglasses to eyeglasses. (Turn eyeglasses attribute on)
```
./translate_one_image.py --config ../exps/celeba_blond_hair.yaml --image_name ../images/ian.jpg --output_image_name ../results/ian_to_eyeglasses.jpg --weights ../snapshots/celeba_eyeglasses_gen_00500000.pkl --a2b 0
```
![No-eyeglasses to eyeglasses](./results/ian_to_eyeglasses.jpg)
From smiling to neutral. (Turn smiling attribute off)
```
./translate_one_image.py --config ../exps/celeba_blond_hair.yaml --image_name ../images/ian.jpg --output_image_name ../results/ian_to_no_smiling.jpg --weights ../snapshots/celeba_smiling_gen_00500000.pkl --a2b 1
```
![Smiling to neutral](./results/ian_to_no_smiling.jpg)
### Example Results
[1] thermal IR image to color image translation (Left, input and right, translation.)
![](./docs/ir2vis.jpg)
![](./docs/vis2ir.jpg)
[2] rainy day image to sunny day image translation (Left, input and right, translation.)
![](./docs/rain2sunny.jpg)
![](./docs/sunny2rain.jpg)
[3] night time image to day time image translation (Left, input and right, translation.)
![](./docs/night2day.jpg)
![](./docs/day2night.jpg)
![](./docs/face_visualization.jpg)
###### Cat to Tiger Translation
1. Download the pretrained model in [link](https://drive.google.com/open?id=0BwpOatrZwxK6V1Bwai1GZFQ2Q0k) to <outputs/unit/cat2tiger>
2. Go to <src> and run to translate the first cat and second cat to tigers
```
python cocogan_translate_one_image.py --config ../exps/unit/cat2tiger.yaml --a2b 1 --weights ../outputs/unit/cat2tiger/cat2tiger_gen_00500000.pkl --image_name ../images/cat001.jpg --output_image_name ../results/cat2tiger_cat001.jpg
```
```
python cocogan_translate_one_image.py --config ../exps/unit/cat2tiger.yaml --a2b 1 --weights ../outputs/unit/cat2tiger/cat2tiger_gen_00500000.pkl --image_name ../images/cat002.jpg --output_image_name ../results/cat2tiger_cat002.jpg
```
### One Example
Training for attribute-based face image translation.
4. Check out the results in <results>. Left: Input. Right: Output
- ![](./results/cat2tiger_cat001.jpg)
- ![](./results/cat2tiger_cat002.jpg)
###### Corgi to Husky Translation
1. Download the pretrained model in [link](https://drive.google.com/open?id=0BwpOatrZwxK6NktUSWZRNE14Ym8) to <outputs/unit/corgi2husky>
- Step 1. Download the file img_aligned_celeba.zip based on the instructions in [CelebA dataset](http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html) and unzip it to datasets/celeba/img_align_celeba/ folder
- Step 2. Crop and resize CelebA images.
2. Go to <src> and run to translate the first cat and second cat to tigers
```
cd datasets/celeba/
./crop_and_resize.py
python cocogan_translate_one_image.py --config ../exps/unit/corgi2husky.yaml --a2b 1 --weights ../outputs/unit/corgi2husky/corgi2husky_gen_00500000.pkl --image_name ../images/corgi001.jpg --output_image_name ../results/corgi2husky_corgi001.jpg
```
- Step 3. Write an experiment config file. Follow the example config file in exps/celeba_blond_hair.yaml
- Step 4. Training
```
python train.py --config ../exps/celeba_blond_hair.yaml --log ../logs;
python cocogan_translate_one_image.py --config ../exps/unit/corgi2husky.yaml --a2b 0 --weights ../outputs/unit/corgi2husky/corgi2husky_gen_00500000.pkl --image_name ../images/husky001.jpg --output_image_name ../results/husky2corgi_husky001.jpg
```
- Step 5. Testing
4. Check out the results in <results>. Left: Input. Right: Output
- ![](./results/corgi2husky_corgi001.jpg)
- ![](./results/husky2corgi_husky001.jpg)
#### Training
1. Download the aligned and crop version of the [CelebA dataset](http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html) to <datasets/celeba>.
2. Go to <datasets/celeba> and crop the middle region of the face images and resize them to 128x128
```
python translate_one_image.py --config ../exps/celeba_blond_hair.yaml --image ../images/032162.jpg --weights ../outputs/celeba_blond_hair/celeba_blond_hair_gen_00500000.pkl --a2b 0 --output ../results/032162_with_blond_hair.jpg
python crop_and_resize.py;
```
3. Setup the yaml file. Check out <exps/unit/blondhair.yaml>
4. Do training
```
python cocogan_train.py --config ../exps/unit/blondhair.yaml --log ../logs
```
5. Resume training
```
python cocogan_train.py --config ../exps/unit/blondhair.yaml --log ../logs --resume 1
```
6. Intermediate image outputs and model binary files are in <outputs/unit/blondhair>
View
@@ -38,15 +38,15 @@ train:
train_a: # Domain 1 dataset
channels: 3 # image channel number
scale: 1.0 # scaling factor for scaling image before processing
crop_image_size: 132 # crop image size
crop_image_size: 128 # crop image size
class_name: dataset_celeba # dataset class name
root: ../datasets/celeba/ # dataset folder location
folder: img_align_crop_resize_celeba/
list_name: lists/Blond_Hair_ON.txt
train_b: # Domain 2 dataset
channels: 3 # image channel number
scale: 1.0 # scaling factor for scaling image before processing
crop_image_size: 132 # crop image size
crop_image_size: 128 # crop image size
class_name: dataset_celeba # dataset class name
root: ../datasets/celeba/ # dataset folder location
folder: img_align_crop_resize_celeba/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 42a8762

Please sign in to comment.