DCGAN & StyleGAN

अब हम GANs की दुनिया के दो सबसे शक्तिशाली और लोकप्रिय versions की ओर बढ़ते हैं —
🌀 DCGAN (Deep Convolutional GAN) और 🎨 StyleGAN

ये दोनों GAN architectures image generation में breakthrough साबित हुए हैं।


🔶 1. DCGAN (Deep Convolutional GAN)

📌 परिचय:

DCGAN एक Convolutional आधारित GAN architecture है जिसे 2015 में Radford, Metz, and Chintala ने प्रस्तावित किया था।

🎯 “यह पहला scalable और stable GAN architecture था जो high-quality images generate कर सका।”


🧠 Key Features:

विशेषताविवरण
📦 Conv LayersGenerator और Discriminator दोनों में Convolutional layers
🧹 No PoolingPooling की जगह stride और transposed conv
🔍 BatchNormStability और convergence के लिए
📈 ReLU & LeakyReLUActivation functions
🔥 SimplicitySimple architecture + Amazing results

🧱 DCGAN Architecture:

Generator:

Input: Random noise vector (z)
→ Fully connected layer
→ Transposed Conv + BatchNorm + ReLU
→ Transposed Conv + BatchNorm + ReLU
→ Transposed Conv + Tanh
→ Output: Fake image

Discriminator:

Input: Image (real/fake)
→ Conv + BatchNorm + LeakyReLU
→ Conv + BatchNorm + LeakyReLU
→ Flatten
→ Fully connected layer + Sigmoid
→ Output: Real/Fake Probability

🔧 PyTorch Library Support:

nn.ConvTranspose2d   # For upsampling (Generator)
nn.Conv2d # For downsampling (Discriminator)
nn.BatchNorm2d # For stability
nn.Tanh / nn.LeakyReLU

🧪 Applications:

  • Handwritten digits (MNIST)
  • Anime faces, bedrooms, shoes
  • Prototype generation for design

🔷 2. StyleGAN (Style-based GAN)

📌 परिचय:

StyleGAN को NVIDIA ने 2018 में Introduce किया था (Karras et al.).
यह अब तक का सबसे realistic face generator माना जाता है।

🎯 “This Person Does Not Exist” जैसी websites StyleGAN पर आधारित हैं।


🧠 Key Features:

विशेषताविवरण
🎨 Style-based architectureNoise vector को style vectors में बदलना
🧬 Progressive GrowingLow-res से high-res तक धीरे-धीरे training
🧠 AdaINAdaptive Instance Normalization for style control
🌈 Latent Space ControlFace features को tune करना (e.g., smile, age)
📸 High-Res1024×1024 तक की photo-quality image generation

🧱 StyleGAN Architecture (Simplified)

Input: Random vector z  
→ Mapping Network → Style vector w
→ Synthesis Network
→ Starts from constant image
→ Multiple conv blocks
→ AdaIN modulation
→ Output: High-quality image

🔁 Style Mixing:

StyleGAN अलग-अलग layers पर अलग-अलग styles apply करके
face blending और feature control करता है।

LayerControls
Early layersPose, layout
Mid layersFacial features
Late layersSkin tone, hair texture, color

🧪 Applications:

क्षेत्रउपयोग
🎭 Face GenerationHyper-realistic faces
🖼️ Art & DesignStyle morphing
🎮 Game DevCharacter creation
🎥 Movie FXVirtual avatars
🔬 BiologySynthetic cell generation

🔍 DCGAN vs StyleGAN

FeatureDCGANStyleGAN
Year20152018
ArchitectureCNN-basedStyle-based
Output QualityGoodUltra-Realistic
ControlNoneHigh (Style mixing)
Latent VectorDirectly usedTransformed via Mapping
ApplicationsSimple image genHuman faces, art, avatars
TrainingStableComplex, resource-heavy

📝 Practice Questions:

  1. DCGAN में Generator और Discriminator कैसे काम करते हैं?
  2. StyleGAN में style control कैसे किया जाता है?
  3. DCGAN और StyleGAN में क्या फर्क है?
  4. AdaIN क्या होता है और क्यों जरूरी है?
  5. Progressive Growing क्या है?

📌 Summary Table

ModelUseKey Feature
DCGANSimple image generationCNN-based Generator
StyleGANHigh-resolution faces, artStyle control, AdaIN, mixing