Skip to content

hichoe95/Artifact-Detection-and-Sequential-Ablation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Can We Find Neurons that Cause Unrealistic Images in Deep Generative Networks?(IJCAI-2022)

Artifact Detection/Correction - Official PyTorch Implementation

This repo provides the official PyTorch implementation of the following paper:

Can We Find Neurons that Cause Unrealistic Images in Deep Generative Networks?
Hwanil Choi, Wonjoon Chang, Jaesik Choi*
Korea Advanced Institute of Science and Technology, KAIST

Abstract
Even though image generation with Generative Adversarial Networks (GANs) has been showing remarkable ability to generate high-quality images, GANs do not always guarantee photorealistic images will be generated. Sometimes they generate images that have defective or unnatural objects, which are referred to as 'artifacts'. Research to determine why the artifacts emerge and how they can be detected and removed has not been sufficiently carried out. To analyze this, we first hypothesize that rarely activated neurons and frequently activated neurons have different purposes and responsibilities for the progress of generating images. By analyzing the statistics and the roles for those neurons, we empirically show that rarely activated neurons are related to failed results of making diverse objects and lead to artifacts. In addition, we suggest a correction method, called 'sequential ablation', to repair the defective part of the generated images without complex computational cost and manual efforts.
https://arxiv.org/abs/2201.06346 https://www.ijcai.org/proceedings/2022/400

Dependencies

  • PyTorch 1.4.0
  • python 3.6
  • cuda 10.0.x
  • cudnn 7.6.3

Pre-Trained Weights (Official) - GenForce

Dataset \ Model PGGAN StyleGAN2
CelebA-HQ (Official) 1024 x 1024 X
FFHQ (Official) X 1024 X 1024
LSUN-Church (Official) 256 x 256 256 x 256
LSUN-CAT (Official) 256 x 256 256 x 256

For following implementation, download StyleGAN2 FFHQ weights in current directory. Otherwise, you should change the '--weight_path' option to your directory.

More pre-trained weights are available in genforce-model-zoo

Implementation

  • Options
optional arguments:
  -h, --help                show this help message and exit
  --gpu GPU                 gpu index number
  --batch_size BATCH_SIZE
                            batch size for pre processing and generating process
  --sample_size SAMPLE_SIZE
                            sample size for statistics
  --freq_path FREQ_PATH
                            loading saved frequencies of neurons
  --model MODEL             pggan, styelgan2
  --dataset DATASET         ffhq, cat, church, etc
  --resolution RESOLUTION
                            dataset resolution
  --weight_path WEIGHT_PATH
                            pre-trained weight path
  --detection DETECTION
                            implement normal/artifact detection
  --correction CORRECTION
                            implement correction task

  • Usage
python main.py --gpu 0 --batch_size 30 --sample_size 30000 --freq_pth ./stats \
               --model stylegan2 --dataset ffhq --resolution 1024 --weight_path ./ \
               --detection True --correction True      

If you are on remote server, then to show the results, you should do the following. (X11 forwarding).

You can also implement our codes in 'Jupyter Notebook' that has more degree of freedom. Use the 'notebook.ipynb' file.

Detection results for 50K samples

Bottom 60 images

Top 60 images

Correction results & Masking part of artifact

Citation

@inproceedings{ijcai2022-400,
  title     = {Can We Find Neurons that Cause Unrealistic Images in Deep Generative Networks?},
  author    = {Choi, Hwanil and Chang, Wonjoon and Choi, Jaesik},
  booktitle = {Proceedings of the Thirty-First International Joint Conference on
               Artificial Intelligence, {IJCAI-22}},
  publisher = {International Joint Conferences on Artificial Intelligence Organization},
  editor    = {Lud De Raedt},
  pages     = {2888--2894},
  year      = {2022},
  month     = {7},
  note      = {Main Track}
  doi       = {10.24963/ijcai.2022/400},
  url       = {https://doi.org/10.24963/ijcai.2022/400},
}

LICENSE

MIT LICENSE

About

[IJCAI-2022] Can We Find Neurons that Cause Unrealistic Images in Deep Generative Networks?

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published