Skip to content

Latest commit

ย 

History

History
59 lines (44 loc) ยท 2.68 KB

facebookresearch_pytorch-gan-zoo_dcgan.md

File metadata and controls

59 lines (44 loc) ยท 2.68 KB
layout background-class body-class title summary category image author tags github-link github-id featured_image_1 featured_image_2 accelerator demo-model-link order
hub_detail
hub-background
hub
DCGAN on FashionGen
64x64 ์ด๋ฏธ์ง€ ์ƒ์„ฑ์„ ์œ„ํ•œ ๊ธฐ๋ณธ ์ด๋ฏธ์ง€ ์ƒ์„ฑ ๋ชจ๋ธ
researchers
dcgan_fashionGen.jpg
FAIR HDGAN
vision
generative
facebookresearch/pytorch_GAN_zoo
dcgan_fashionGen.jpg
no-image
cuda-optional
10
import torch
use_gpu = True if torch.cuda.is_available() else False

model = torch.hub.load('facebookresearch/pytorch_GAN_zoo:hub', 'DCGAN', pretrained=True, useGPU=use_gpu)

๋ชจ๋ธ์— ์ž…๋ ฅํ•˜๋Š” ์žก์Œ(noise) ๋ฒกํ„ฐ์˜ ํฌ๊ธฐ๋Š” (N, 120) ์ด๋ฉฐ ์—ฌ๊ธฐ์„œ N์€ ์ƒ์„ฑํ•˜๊ณ ์ž ํ•˜๋Š” ์ด๋ฏธ์ง€์˜ ๊ฐœ์ˆ˜์ž…๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ ์ƒ์„ฑ์€ .buildNoiseData ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ชจ๋ธ์˜ .test ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์žก์Œ ๋ฒกํ„ฐ๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

num_images = 64
noise, _ = model.buildNoiseData(num_images)
with torch.no_grad():
    generated_images = model.test(noise)

# torchvision ๊ณผ matplotlib ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€๋“ค์„ ์‹œ๊ฐํ™”ํ•ฉ๋‹ˆ๋‹ค.
import matplotlib.pyplot as plt
import torchvision
plt.imshow(torchvision.utils.make_grid(generated_images).permute(1, 2, 0).cpu().numpy())
# plt.show()

์™ผ์ชฝ์— ์žˆ๋Š” ์ด๋ฏธ์ง€์™€ ์œ ์‚ฌํ•˜๋‹ค๋Š”๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋งŒ์•ฝ ์ž๊ธฐ๋งŒ์˜ DCGAN๊ณผ ๋‹ค๋ฅธ GAN์„ ์ฒ˜์Œ๋ถ€ํ„ฐ ํ•™์Šต์‹œํ‚ค๊ณ  ์‹ถ๋‹ค๋ฉด, PyTorch GAN Zoo ๋ฅผ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

๋ชจ๋ธ ์„ค๋ช…

์ปดํ“จํ„ฐ ๋น„์ „ ๋ถ„์•ผ์—์„œ ์ƒ์„ฑ ๋ชจ๋ธ์€ ์ฃผ์–ด์ง„ ์ž…๋ ฅ์— ๋Œ€ํ•œ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•˜๋„๋ก ํ›ˆ๋ จ๋œ ๋„คํŠธ์›Œํฌ(networks)์ž…๋‹ˆ๋‹ค. ๋ณธ ์˜ˆ์ œ์—์„œ๋Š” ๋ฌด์ž‘์œ„ ๋ฒกํ„ฐ์™€ ์‹ค์ œ ์ด๋ฏธ์ง€ ์ƒ์„ฑ ๊ฐ„์˜ ์—ฐ๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์šฐ๋Š” GANs (Generative Adversarial Networks) ์œผ๋กœ ํŠน์ • ์ข…๋ฅ˜์˜ ์ƒ์„ฑ ๋„คํŠธ์›Œํฌ๋ฅผ ์‚ดํŽด๋ด…๋‹ˆ๋‹ค.

DCGAN์€ 2015๋…„ Radford ๋“ฑ์ด ์„ค๊ณ„ํ•œ ๋ชจ๋ธ ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค. ์ƒ์„ธํ•œ ๋‚ด์šฉ์€ Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks ๋…ผ๋ฌธ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ชจ๋ธ์€ GAN ๊ตฌ์กฐ์ด๋ฉฐ ์ €ํ•ด์ƒ๋„ ์ด๋ฏธ์ง€ (์ตœ๋Œ€ 64x64) ์ƒ์„ฑ์— ๋งค์šฐ ๊ฐ„ํŽธํ•˜๊ณ  ํšจ์œจ์ ์ž…๋‹ˆ๋‹ค.

์š”๊ตฌ ์‚ฌํ•ญ

  • ํ˜„์žฌ๋Š” ์˜ค์ง Python 3 ์—์„œ๋งŒ ์ง€์›๋ฉ๋‹ˆ๋‹ค.

์ฐธ๊ณ ๋ฌธํ—Œ