Assignment 3: Cats Generator Playground - 16-726: Learning-Based Image Synthesis - prabhdes

Part 1: Deep Convolutional GAN (DCGAN)

Data Augmentation

Basic Transform:

basic_transform = transforms.Compose([
    transforms.Resize(opts.image_size, Image.BICUBIC),
    transforms.ToTensor(),
    transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
])

Deluxe Transform:

deluxe_transform = transforms.Compose([
    transforms.Resize(osize, Image.BICUBIC),
    transforms.RandomCrop(opts.image_size),
    transforms.RandomHorizontalFlip(),
    transforms.ToTensor(),
    transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
])

Discriminator of the DCGAN (Kernel and Padding Information)

self.up_conv1 = nn.Conv2d(in_channels=noise_size, out_channels=256, kernel_size=2, stride=1, padding=2)
self.bn1 = nn.InstanceNorm2d(256)
self.up_conv2 = up_conv(in_channels=256, out_channels=128, kernel_size=3, stride=1, padding=1, scale_factor=2, norm="instance", activ="relu")
self.up_conv3 = up_conv(in_channels=128, out_channels=64, kernel_size=3, stride=1, padding=1, scale_factor=2, norm="instance", activ="relu")
self.up_conv4 = up_conv(in_channels=64, out_channels=32, kernel_size=3, stride=1, padding=1, scale_factor=2, norm="instance", activ="relu")
self.up_conv5 = up_conv(in_channels=32, out_channels=3, kernel_size=3, stride=1, padding=1, scale_factor=2, norm=None, activ="tanh")

Generator of the DCGAN (Kernel and Padding Information)

self.conv1 = conv(3, 32, 4, 2, 1, norm, True, 'relu')
self.conv2 = conv(in_channels=32, out_channels=64, kernel_size=4, stride=2, padding=1, norm=norm, init_zero_weights=False, activ="leaky")
self.conv3 = conv(in_channels=64, out_channels=128, kernel_size=4, stride=2, padding=1, norm=norm, init_zero_weights=False, activ="leaky")
self.conv4 = conv(in_channels=128, out_channels=256, kernel_size=4, stride=2, padding=1, norm=norm, init_zero_weights=False, activ="leaky")
self.conv5 = conv(in_channels=256, out_channels=1, kernel_size=4, stride=2, padding=1, norm=None, init_zero_weights=False, activ=None)

Differentiable Augmentation

Results and Explanation:

DCGAN & Basic Augmentation & Differential Augmentation:

dc_basic dc_basic_diff
Left - DCGAN + Basic Augmentation | Right: DCGAN + Basic Augmentation + Differential Augmentation

DCGAN & Deluxe Augmentation & Differential Augmentation:
dc_deluxe dc_deluxe_diff
Left: DCGAN + Deluxe Augmentation | Right: DCGAN + Deluxe Augmentation + Differential Augmentation

Explanation

Utilizing deluxe augmentation and differentiable augmentation significantly improves image quality. Differentiable augmentation, in particular, addresses the Generator's challenges in replicating augmented images, thereby reducing artifacts and enhancing convergence and quality through discriminator regularization. The DCGAN's progress is evident from the decreasing losses of both the discriminator and generator. Notably, the discriminator loss is higher, and the generator loss is lower when differentiable augmentation is used, attributed to the improved regularization. The contrast in loss curves between basic and deluxe augmentation strategies is not substantial.

Loss Curves:

D_Total:
d_loss
G_Total:
g_loss

Explanation:

The initial high G loss curve indicates the Generator's struggle to create convincing images, which gradually decreases as its performance improves. However, unlike the D loss, the G loss may continue to show fluctuations or a downward trend, reflecting the Generator's ongoing efforts to deceive the Discriminator. The use of deluxe data processing and data augmentation results in a lower G loss curve, signifying better image generation. The DCGAN's results after 6,400 iterations, with both basic and deluxe data preprocessing and differential augmentations, show that differential augmentations enhance image quality by reducing artifacts and increasing lifelike features. This improvement is noticeable in later training stages, where images exhibit greater realism and detail, indicating the GAN's progress in generating images that increasingly resemble real ones.

Comparison of Early and Late Training Results:

Both Results are from the config: DCGAN + Deluxe Augmentation + Differential Augmentation
dc_deluxe_diff_early dc_deluxe_diff_late
Left: Iteration 200 | Right: Iteration 6400

Part 2: CycleGAN

Early Results - 1000 Iterations - Grumpy Cat:

Results Without Cycle Consistency:

cg_x2y_early cg_y2x_early
Left: X2Y | Right: Y2X

Results With Cycle Consistency:

cg_x2y_early_cycle cg_y2x_early_cycle
Left: X2Y | Right: Y2X

Extended Results - 10000 Iterations - Grumpy Cat:

Results Without Cycle Consistency:

cg_x2y cg_y2x
Left: X2Y | Right: Y2X

Results With Cycle Consistency:

cg_x2y_cycle cg_y2x_cycle
Left: X2Y | Right: Y2X

Extended Results - 10000 Iterations - apple2orange

Results Without Cycle Consistency:

cg_x2y_orange2apple cg_y2x_orange2apple
Left: X2Y | Right: Y2X

Results With Cycle Consistency:

cg_x2y_cycle_orange2apple cg_y2x_cycle_orange2apple
Left: X2Y | Right: Y2X

Discussion on Importance of Cycle Consistency Loss:

The inclusion of cycle-consistency loss in the CycleGAN model significantly improves the realism of the generated images, ensuring they closely resemble the original input in both content and style. This loss function is crucial for maintaining the integrity of the input's domain characteristics, leading to more authentic and visually appealing results. It also aids in preserving essential attributes and textures, resulting in coherent and detailed outputs that narrow the gap between generated and real images. Moreover, cycle consistency loss enhances image quality, evident in sharper details and reduced artifacts, which we can see fromm the above results. It also introduces greater diversity in the results, as seen in the cats dataset, where the model effectively captures facial features.

Effect of Changing Discriiminator:

DCDiscriminator - 10000 Iterations - Grumpy Cat:

Results Without Cycle Consistency:

cg_x2y_disc cg_y2x_disc
Left: X2Y | Right: Y2X

Results With Cycle Consistency:

cg_x2y_cycle_disc cg_y2x_cycle_disc
Left: X2Y | Right: Y2X

DCDiscriminator - 10000 Iterations - apple2orange:

Results Without Cycle Consistency:

cg_x2y_orange2apple_disc cg_y2x_orange2apple_disc
Left: X2Y | Right: Y2X

Results With Cycle Consistency:

cg_x2y_cycle_orange2apple_disc cg_y2x_cycle_orange2apple_disc
Left: X2Y | Right: Y2X

Discussion on Effect of Changing Discriiminator:

The DC-Discriminator tends to produce less realistic images compared to the patch discriminator, which assesses images on a patch-by-patch basis. This localized approach enables the patch discriminator to focus on fine-grained details and textures, leading to more nuanced assessments of image realism. In contrast, the DC-Discriminator evaluates the image as a whole, which may result in overlooking finer details that contribute to the perception of realism. Our results have shown that the patch discriminator approach results in sharper images, while the DC-Discriminator approach exhibits a slight decrease in sharpness, with more blurred and artifact-laden images. However, the difference between the two approaches is subtle, as the patch discriminator ensures the authenticity of each image segment, while the DC-Discriminator focuses on the overall authenticity of the entire image, potentially compromising the authenticity of individual subsections.

Part 3: Bells and Whistles

2: Generate Samples Using a Pre-trained Diffusion Model:

I used the Stable Diffusionn 2.1 Demo on HuggingFace to generate these outputs:
diff_op1 diff_op2 diff_op3 diff_op4

3: CycleGAN with summer2winter dataset:

Config: CycleGAN + Deluxe + Patch + Cycle Consistency + Iter 10000

cg_x2y_cycle_orange2apple cg_y2x_cycle_orange2apple
Left: X2Y | Right: Y2X

5: Meme

meme

6: CycleGAN with higher-resolution dataset:

Config: CycleGAN + Grumpy Cat + Deluxe + Patch + Cycle Consistency + Iter 10000

cg_x2y_cycle_orange2apple cg_y2x_cycle_orange2apple
Left: X2Y | Right: Y2X