๐Ÿ‘ฆ ๋‚ด์ผ๋ฐฐ์›€์บ ํ”„/TIL(Today I Learned)

TIL_220623_๋”ฅ๋Ÿฌ๋‹

  • -

์œ ํ™”์ œ์ž‘ ํ”„๋กœ์ ํŠธ

Style transfer = ์—…๋กœ๋“œํ•œ ์‚ฌ์ง„์„ ์œ ํ™”์ฒ˜๋Ÿผ ๋ณ€ํ™˜ํ•ด์ค€๋‹ค.

 

012

git ์ฐธ๊ณ  : https://github.com/crowsonkb/style-transfer-pytorch

 

GitHub - crowsonkb/style-transfer-pytorch: Neural style transfer in PyTorch.

Neural style transfer in PyTorch. Contribute to crowsonkb/style-transfer-pytorch development by creating an account on GitHub.

github.com

  1. ๊ฐ€์ƒํ™˜๊ฒฝ ์„ค์ • ํ›„ [ pip install -e . ] ์„ค์น˜
  2. style_transfer_pytorch.egg-info ๊ฒฝ๋กœ ์„ค์ •
    • $ cd ~/code/deep_learning/style_transfer_pytorch.egg-info
  3. style_transfer main.jpg backgraound.jpg
    • style_transfer CONTENT_IMAGE STYLE_IMAGE [STYLE_IMAGE ...] [-o OUTPUT_IMAGE]
  4. iterations: int = 500, 500๋ฒˆ ๋Œ์•„์„œ ์•„์›ƒํ’‹ ์ถœ๋ ฅ(์กฐ์ •์— ๋”ฐ๋ผ ํ€„๋ฆฌํ‹ฐ ์กฐ์ • ํ€„๋ฆฌํ‹ฐ์™€ ์‹œ๊ฐ„ ๋น„๋ก€)
    • ์กฐ๊ฑด์ด ํ•„์š”ํ•  ๋“ฏ ํ•˜๋‹ค.
      • ์‚ฌ์ง„ ์šฉ๋Ÿ‰์— ๋Œ€ํ•œ ์ œํ•œ
      • ํ™•์žฅ์ž ์ง€์ • ์•ˆ๋‚ด

 

Q. ์„œ๋น„์Šค ํ•˜๋ ค๋ฉด ์–ด๋Š์ •๋„ ์‹œ๊ฐ„์— ๊ฒฐ๊ณผ๋ฌผ์„ ๋ณด์—ฌ์ค˜์•ผ ํ•˜๋‚˜์š”?

- ๋กœ๋”ฉ์ด ๋˜๋Š” ์‹œ๊ฐ„ ๋™์•ˆ ๋‹ค๋ฅธ ์˜์ƒ์„ ํ‹€์–ด์ฃผ๋Š” ๋“ฑ์˜ ์„œ๋น„์Šค ์ œ๊ณตํ•˜๋Š”๊ฒŒ ์ข‹์„ ๋“ฏ

 

HOW? ์–ด๋–ป๊ฒŒ ์••์ถ•์ด ๋˜๋Š”๊ฐ€?

  1. ๋ณต์› ๊ณผ์ •์€ ์—ฌ๋Ÿฌ๋ฒˆ์˜ ์ชผ๊ฐœ๋Š” ๊ณผ์ •์„ ํ†ตํ•ด ์œ ์‚ฌํ•œ ๋ ˆ์ด์•„์›ƒ์„ ๊ตฌ๋ถ„ํ•œ๋‹ค.
  2. ๋ณต์› ๊ณผ์ •์—์„œ ์Šคํƒ€์ผ์„ ์ž…ํžŒ๋‹ค๊ณ  ๋ณด๋ฉด ๋œ๋‹ค

 

git : https://github.com/AliaksandrSiarohin/first-order-model

 

GitHub - AliaksandrSiarohin/first-order-model: This repository contains the source code for the paper First Order Motion Model f

This repository contains the source code for the paper First Order Motion Model for Image Animation - GitHub - AliaksandrSiarohin/first-order-model: This repository contains the source code for th...

github.com

 

git : https://github.com/genforce/sefa

 

GitHub - genforce/sefa: [CVPR 2021] Closed-Form Factorization of Latent Semantics in GANs

[CVPR 2021] Closed-Form Factorization of Latent Semantics in GANs - GitHub - genforce/sefa: [CVPR 2021] Closed-Form Factorization of Latent Semantics in GANs

github.com

๋”๋ณด๊ธฐ

1. checkpoints ํด๋” ์•ˆ์— ๋ชจ๋ธ ์ €์žฅ

[๋ชจ๋ธ ๋‹ค์šด๋กœ๋“œ ํŽ˜์ด์ง€]
https://github.com/genforce/genforce/blob/master/MODEL_ZOO.md

 

[ํ‚ค์›Œ๋“œ]

car512, anime

 

[๋‹ค์šด๋กœ๋“œํ•œ ํŒŒ์ผ]

stylegan_animeface512.pth

 

2.๋ชจ๋ธ ์„ธํŒ…

MODEL_NAME=stylegan_animeface512
LAYER_IDX=0-1
NUM_SAMPLES=5
NUM_SEMANTICS=5
python sefa.py ${MODEL_NAME} \
    -L ${LAYER_IDX} \
    -N ${NUM_SAMPLES} \
    -K ${NUM_SEMANTICS}

3. pip install

[streamlit ๋ฒ„์ „ ์ถฉ๋Œ์‹œ]
pip uninstall streamlit

[์ •์ƒ๋ฒ„์ „]
1. pip install streamlit==1.3.1
2. pip install opencv-python
3. pip install torch==1.9.0+cu111 (๋ฒ„์ „์˜ค๋ฅ˜) torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

[์ด๊ฑธ๋กœ ์ง„ํ–‰]
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

pip install torch==1.11.0+cu115 -f https://download.pytorch.org/whl/torch_stable.html
pip install torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

4. ์‹คํ–‰
CUDA_VISIBLE_DEVICES=0 streamlit run interface.py

 

git : https://github.com/lucidrains/stylegan2-pytorch

 

GitHub - lucidrains/stylegan2-pytorch: Simplest working implementation of Stylegan2, state of the art generative adversarial net

Simplest working implementation of Stylegan2, state of the art generative adversarial network, in Pytorch. Enabling everyone to experience disentanglement - GitHub - lucidrains/stylegan2-pytorch: S...

github.com

 

git : https://github.com/phillipi/pix2pix

 

GitHub - phillipi/pix2pix: Image-to-image translation with conditional adversarial nets

Image-to-image translation with conditional adversarial nets - GitHub - phillipi/pix2pix: Image-to-image translation with conditional adversarial nets

github.com

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.