GANs का मूल्यांकन

PyTorch के साथ इमेज के लिए डीप लर्निंग

Michal Oleszak

Machine Learning Engineer

इमेज जनरेट करना

num_images_to_generate = 9
noise = torch.randn(num_images_to_generate, 16)

with torch.no_grad(): fake = gen(noise)
print(f"Generated shape: {fake.shape}")
Generated shape: torch.Size([9, 3, 96, 96])
for i in range(num_images_to_generate):

image_tensor = fake[i, :, :, :]
image_permuted = image_tensor.permute(1, 2, 0)
plt.imshow(image_permuted) plt.show()
  • रैंडम noise टेन्सर बनाएँ
  • noise को जेनरेटर में पास करें
  • इमेज की संख्या पर इटरेट करें
  • i-th इमेज चुनने के लिए fake को slice करें
  • इमेज के डायमेंशन पुनर्व्यवस्थित करें
  • इमेज प्लॉट करें
PyTorch के साथ इमेज के लिए डीप लर्निंग

GAN जनरेशंस

GAN द्वारा जनरेट की गई Pokemon इमेज का नमूना.

PyTorch के साथ इमेज के लिए डीप लर्निंग

Fréchet Inception Distance

  • Inception: इमेज क्लासिफिकेशन मॉडल
  • Fréchet distance: दो प्रायिकता वितरणों के बीच दूरी का माप
  • Fréchet Inception Distance:
    1. Inception से real और fake इमेज सैंपल के फीचर निकालें
    2. real और fake फीचर्स के mean और covariance निकालें
    3. real और fake normal वितरणों के बीच Fréchet distance निकालें
  • कम FID = fakes ट्रेनिंग डेटा जैसे और diverse
  • FID < 10 = अच्छा
PyTorch के साथ इमेज के लिए डीप लर्निंग

PyTorch में FID

from torchmetrics.image.fid import \
FrechetInceptionDistance


fid = FrechetInceptionDistance(feature=64)
fid.update( (fake * 255).to(torch.uint8), real=False)
fid.update( (real * 255).to(torch.uint8), real=True)
fid.compute()
tensor(7.5159)
  • FrechetInceptionDistance इम्पोर्ट करें
  • FID मेट्रिक बनाएं
  • fake इमेज से मेट्रिक अपडेट करें:
    • 255 से गुणा करें
    • torch.uint8 में parse करें
  • इसी तरह real इमेज से अपडेट करें
  • मेट्रिक वैल्यू compute करें
PyTorch के साथ इमेज के लिए डीप लर्निंग

अभ्यास करते हैं!

PyTorch के साथ इमेज के लिए डीप लर्निंग

Preparing Video For Download...