본문 바로가기

Data-science/deep learning

[StyleGan2-ada 실습] AFHQ 데이터 셋 이용해서 stylegan2-ada 학습하기 2

반응형

Stylegan2-ada 뭐가 달라진 걸까?

  • We propose an adaptive discriminator augmentation mechanism that significantly stabilizes training in limited data regimes.

ada(adaptive discriminator augmentation) 라는 증강 기법이 추가됨. 이 메커니즘만으로 학습을 상당히 안정화 시킴

  • The approach does not require changes to loss functions or network architectures, and is applicable both when training from scratch and when fine-tuning an existing GAN on another dataset. 

loss 함수도, 네트워크 구조 변화도 없다.

(github 참조)

  • ADA: 3만 개 미만의 CIFAR-10 이미지 학습해서 State-of-the-art 성능찍음
  • Mixed-precision support: 1.6배 까지 학습 가속, 1.3배까지 추론 가속, 1.5배까지 GPU 메모리 소비 줄임
  • Better hyperparameter defaults: 하이퍼파라미터 설정이 더 간편해짐
  • Clean codebase: 코드 리펙토링, 단순화, 사용하기 더 쉬움
  • Command line tools: 논문에 나온데로 학습 가능, 임의의 이미지에 대해서도 투영하는 것도 생성해줌.
  • Network import: 네트워크 가중치를 pkl파일로 사용가능 StyleGAN and StyleGAN2. 네트워크 로딩 시간이 빠르다.
  • Augmentation pipeline: 자체적으로 포함, 초고화질 이미지 증강 기법을 GPU를 이용해서 구현했고 재사용이 가능함. 
  • Bugfixes : 버그도 수정했다고 함

 

 

PathDescription

stylegan2-ada Main directory hosted on Amazon S3
  ├  ada-paper.pdf Paper PDF
  ├  images Curated example images produced using the pre-trained models
  ├  videos Curated example interpolation videos
  └  pretrained Pre-trained models
    ├  metfaces.pkl MetFaces at 1024x1024, transfer learning from FFHQ using ADA
    ├  brecahad.pkl BreCaHAD at 512x512, trained from scratch using ADA
    ├  afhqcat.pkl AFHQ Cat at 512x512, trained from scratch using ADA
    ├  afhqdog.pkl AFHQ Dog at 512x512, trained from scratch using ADA
    ├  afhqwild.pkl AFHQ Wild at 512x512, trained from scratch using ADA
    ├  cifar10.pkl Class-conditional CIFAR-10 at 32x32
    ├  ffhq.pkl FFHQ at 1024x1024, trained using original StyleGAN2
    ├  paper-fig7c-training-set-sweeps All models used in Fig.7c (baseline, ADA, bCR)
    ├  paper-fig8a-comparison-methods All models used in Fig.8a (comparison methods)
    ├  paper-fig8b-discriminator-capacity All models used in Fig.8b (discriminator capacity)
    ├  paper-fig11a-small-datasets All models used in Fig.11a (small datasets, transfer learning)
    ├  paper-fig11b-cifar10 All models used in Fig.11b (CIFAR-10)
    ├  transfer-learning-source-nets Models used as starting point for transfer learning
    └  metrics Feature detectors used by the quality metrics

pretrained afhq 모델이 있다!

1. 이미지 projection

python projector.py --outdir=out --target=targetimg.png \
    --network=https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada/pretrained/afhqcat.pkl

out 폴더내에 결과가 proj.png로, 투영된 latent vector가 dlatents.npz로 저장이 된다. 투영하는 비디오도 proj.mp4로 저장됨.

2. projection 된 latent vectoer 조절해서 이미지 generate 하기

python generate.py --outdir=out --dlatents=out/dlatents.npz \
    --network=https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada/pretrained/afhqcat.pkl

--dlatents로 latent vector를 조절하면 이미지를 랜더링할 수 있음

 

pretrained network로 생성 시도

 

target image: generate image

github.com/NVlabs/stylegan2-ada

 

NVlabs/stylegan2-ada

StyleGAN2 with adaptive discriminator augmentation (ADA) - Official TensorFlow implementation - NVlabs/stylegan2-ada

github.com

반응형