vlbthambawita commited on
Commit
5cb0801
2 Parent(s): df20d82 b2883d7

Merge branch 'main' of https://huggingface.co/deepsynthbody/deepfake_gi_fastGAN into main

Browse files
Files changed (3) hide show
  1. README.md +68 -63
  2. config.json +1 -0
  3. pytorch_model.bin +3 -0
README.md CHANGED
@@ -1,63 +1,68 @@
1
- # A Fast and Stable GAN for Small and High Resolution Imagesets - pytorch
2
- The official pytorch implementation of the paper "Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis", the paper can be found [here](https://arxiv.org/abs/2101.04775).
3
-
4
- ## 0. Data
5
- The datasets used in the paper can be found at [link](https://drive.google.com/file/d/1aAJCZbXNHyraJ6Mi13dSbe7pTyfPXha0/view?usp=sharing).
6
-
7
- After testing on over 20 datasets with each has less than 100 images, this GAN converges on 80% of them.
8
- I still cannot summarize an obvious pattern of the "good properties" for a dataset which this GAN can converge on, please feel free to try with your own datasets.
9
-
10
-
11
- ## 1. Description
12
- The code is structured as follows:
13
- * models.py: all the models' structure definition.
14
-
15
- * operation.py: the helper functions and data loading methods during training.
16
-
17
- * train.py: the main entry of the code, execute this file to train the model, the intermediate results and checkpoints will be automatically saved periodically into a folder "train_results".
18
-
19
- * eval.py: generates images from a trained generator into a folder, which can be used to calculate FID score.
20
-
21
- * benchmarking: the functions we used to compute FID are located here, it automatically downloads the pytorch official inception model.
22
-
23
- * lpips: this folder contains the code to compute the LPIPS score, the inception model is also automatically download from official location.
24
-
25
- * scripts: this folder contains many scripts you can use to play around the trained model. Including:
26
- 1. style_mix.py: style-mixing as introduced in the paper;
27
- 2. generate_video.py: generating a continuous video from the interpolation of generated images;
28
- 3. find_nearest_neighbor.py: given a generated image, find the closest real-image from the training set;
29
- 4. train_backtracking_one.py: given a real-image, find the latent vector of this image from a trained Generator.
30
-
31
- ## 2. How to run
32
- Place all your training images in a folder, and simply call
33
- ```
34
- python train.py --path /path/to/RGB-image-folder
35
- ```
36
- You can also see all the training options by:
37
- ```
38
- python train.py --help
39
- ```
40
- The code will automatically create a new folder (you have to specify the name of the folder using --name option) to store the trained checkpoints and intermediate synthesis results.
41
-
42
- Once finish training, you can generate 100 images (or as many as you want) by:
43
- ```
44
- cd ./train_results/name_of_your_training/
45
- python eval.py --n_sample 100
46
- ```
47
-
48
- ## 3. Pre-trained models
49
- The pre-trained models and the respective code of each model are shared [here](https://drive.google.com/drive/folders/1nCpr84nKkrs9-aVMET5h8gqFbUYJRPLR?usp=sharing).
50
-
51
- You can also use FastGAN to generate images with a pre-packaged Docker image, hosted on the Replicate registry: https://beta.replicate.ai/odegeasslbc/FastGAN
52
-
53
- ## 4. Important notes
54
- 1. The provided code is for research use only.
55
- 2. Different model and training configurations are needed on different datasets. You may have to tune the hyper-parameters to get the best results on your own datasets.
56
-
57
- 2.1. The hyper-parameters includes: the augmentation options, the model depth (how many layers), the model width (channel numbers of each layer). To change these, you have to change the code in models.py and train.py directly.
58
-
59
- 2.2. Please check the code in the shared pre-trained models on how each of them are configured differently on different datasets. Especially, compare the models.py for ffhq and art datasets, you will get an idea on what chages could be made on different datasets.
60
-
61
- ## 5. Other notes
62
- 1. The provided scripts are not well organized, contributions are welcomed to clean them.
63
- 2. An third-party implementation of this paper can be found [here](https://github.com/lucidrains/lightweight-gan), where some other techniques are included. I suggest you try both implementation if you find one of them does not work.
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ ---
6
+ # A Fast and Stable GAN for Small and High Resolution Imagesets - pytorch
7
+ The official pytorch implementation of the paper "Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis", the paper can be found [here](https://arxiv.org/abs/2101.04775).
8
+
9
+ ## 0. Data
10
+ The datasets used in the paper can be found at [link](https://drive.google.com/file/d/1aAJCZbXNHyraJ6Mi13dSbe7pTyfPXha0/view?usp=sharing).
11
+
12
+ After testing on over 20 datasets with each has less than 100 images, this GAN converges on 80% of them.
13
+ I still cannot summarize an obvious pattern of the "good properties" for a dataset which this GAN can converge on, please feel free to try with your own datasets.
14
+
15
+
16
+ ## 1. Description
17
+ The code is structured as follows:
18
+ * models.py: all the models' structure definition.
19
+
20
+ * operation.py: the helper functions and data loading methods during training.
21
+
22
+ * train.py: the main entry of the code, execute this file to train the model, the intermediate results and checkpoints will be automatically saved periodically into a folder "train_results".
23
+
24
+ * eval.py: generates images from a trained generator into a folder, which can be used to calculate FID score.
25
+
26
+ * benchmarking: the functions we used to compute FID are located here, it automatically downloads the pytorch official inception model.
27
+
28
+ * lpips: this folder contains the code to compute the LPIPS score, the inception model is also automatically download from official location.
29
+
30
+ * scripts: this folder contains many scripts you can use to play around the trained model. Including:
31
+ 1. style_mix.py: style-mixing as introduced in the paper;
32
+ 2. generate_video.py: generating a continuous video from the interpolation of generated images;
33
+ 3. find_nearest_neighbor.py: given a generated image, find the closest real-image from the training set;
34
+ 4. train_backtracking_one.py: given a real-image, find the latent vector of this image from a trained Generator.
35
+
36
+ ## 2. How to run
37
+ Place all your training images in a folder, and simply call
38
+ ```
39
+ python train.py --path /path/to/RGB-image-folder
40
+ ```
41
+ You can also see all the training options by:
42
+ ```
43
+ python train.py --help
44
+ ```
45
+ The code will automatically create a new folder (you have to specify the name of the folder using --name option) to store the trained checkpoints and intermediate synthesis results.
46
+
47
+ Once finish training, you can generate 100 images (or as many as you want) by:
48
+ ```
49
+ cd ./train_results/name_of_your_training/
50
+ python eval.py --n_sample 100
51
+ ```
52
+
53
+ ## 3. Pre-trained models
54
+ The pre-trained models and the respective code of each model are shared [here](https://drive.google.com/drive/folders/1nCpr84nKkrs9-aVMET5h8gqFbUYJRPLR?usp=sharing).
55
+
56
+ You can also use FastGAN to generate images with a pre-packaged Docker image, hosted on the Replicate registry: https://beta.replicate.ai/odegeasslbc/FastGAN
57
+
58
+ ## 4. Important notes
59
+ 1. The provided code is for research use only.
60
+ 2. Different model and training configurations are needed on different datasets. You may have to tune the hyper-parameters to get the best results on your own datasets.
61
+
62
+ 2.1. The hyper-parameters includes: the augmentation options, the model depth (how many layers), the model width (channel numbers of each layer). To change these, you have to change the code in models.py and train.py directly.
63
+
64
+ 2.2. Please check the code in the shared pre-trained models on how each of them are configured differently on different datasets. Especially, compare the models.py for ffhq and art datasets, you will get an idea on what chages could be made on different datasets.
65
+
66
+ ## 5. Other notes
67
+ 1. The provided scripts are not well organized, contributions are welcomed to clean them.
68
+ 2. An third-party implementation of this paper can be found [here](https://github.com/lucidrains/lightweight-gan), where some other techniques are included. I suggest you try both implementation if you find one of them does not work.
config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"ngf": 64, "noise_dim": 256, "nc": 4, "im_size": 256}
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bcae4a10c47c9b53c30fd69b4b658be4751294a2fc12aab3ba4f016b50ed56eb
3
+ size 116856197