0% found this document useful (0 votes)
5 views80 pages

Report Update

Uploaded by

sparshdavra0795
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views80 pages

Report Update

Uploaded by

sparshdavra0795
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

END TERM REPORT

on
GAN-Based Medical Image Generation: Advanced
Architecture Extensions
Submitted in fulfillment of the requirement of
Project Phase – II

Submitted by
Sparsh Davra
SAP ID - 590011376

ENROLLMENT NUMBER - 24010310846


Dr. Chandra Mani Sharma
Dr. Juhi Agrawal

School of Computer Science (SoCS)


University of Petroleum and Energy Studies
Dehradun, Uttarakhand, India-248001
(2024-2026)
School of Computer Science & Engineering
University of Petroleum and Energy Studies
Dehradun, Uttarakhand, India – 248001
Website: [Link]

Candidate’s Declaration
I hereby declare that the work presented in this thesis entitled “GAN-Based Medical Image Generation:
Advanced Architecture Extensions” in fulfilment of the requirements for the award of Degree of Master of
Technology and submitted in the School of Computer Science and Engineering at University of Petroleum and
Energy Studies is an authentic record of my own work carried out during a period of August 2024 to May 2026
under the supervision of Dr. Chandra Mani Sharma and Dr. Juhi Agrawal, School of Computer Science and
Engineering, University of Petroleum and Energy Studies.

Sparsh Davra
(SAP-ID – 590011376)
This is to certify that the above statement made by the candidate is true to the best of our knowledge and belief

Place: UPES, Dehradun


Date: 08-05-2026

i
School of Computer Science & Engineering
University of Petroleum and Energy Studies
Dehradun, Uttarakhand, India – 248001
Website: [Link]

Certificate
This is to certify that the thesis entitled “GAN-Based Medical Image Generation: Advanced Architecture
Extensions” submitted by Sparsh Davra (SAP-ID 590011376) to University of Petroleum and Energy
Studies is record of bonafide research work carried under my supervision and is worthy of consideration for the
award of the degree of Master of Technology of the University.
To the best of our knowledge, the works continued in the thesis have not been submitted in part of full to
elsewhere for any degree or diploma.

Dr. Chandra Mani Sharma Dr. Juhi Agrawal


Assistant Dean Associate Professor
School of Computer Science School of Computer Science
University of Petroleum and University of Petroleum and Energy
Energy Studies Studies

ii
ACKNOWLEDGEMENT

It is with profound pleasure and sense of immense gratitude, that I convey my heartiest thanks
to Dr. Chandra Mani Sharma, Associate Dean(Academics) School of Computer Science,
University of Petroleum and Energy Studies (UPES), Dehradun, for providing an apt guidance,
keen interest and a perpetual support for the present research. His guidance, insight, and
encouragement provided immense importance for the direction and quality of the dissertation.
Further, I express my deep sense of gratitude to Dr. Juhi Agrawal for providing relevant
suggestions, positive feedback and constant support, which were greatly influential in the overall
improvement of this project. I feel great indebted to the School of Computer Science at UPES,
Dehradun for its academic environment and providing the infrastructure and resources.

I would also like to thank all the researchers and authors that have been cited in this dissertation.
Those are the defining works that guided my research and gave me a solid foundation for it. I
owe many thanks to my friends and mates for their continuous assistance, discussions and
motivation during my study. You inspired and kept my spirit up when the chips were down. Last
but not least --- A special note of gratitude and love to my family who stood by me
unconditionally believing and having faith in me throughout this journey.

(Sparsh Davra)

iii
ABSTRACT
When it comes to the professionalism of the physicians in obtaining & labelling
Imaging studies, there are many extreme practical limitations on obtaining a set of
data to train a deep learning-derived diagnostic system. Due to the extreme cost of
both Imaging acquisition as well as the manual labelling that accompanies imaging,
data scarcity is a major problem in the practical medical setting. A Generative
Adversarial Network (GAN) is a method for solving the problem of data scarcity.
GANs synthesize photorealistic images by learning from a statistical distribution. The
purpose of this two-phase study is to design, develop, and validate a GAN framework
that is capable of synthesizing high-resolution medical images with state-of-the-art
performance.

Project Phase I, created a basic proof-of-concept trained Deep Convolutional GAN


using 3,616 COVID-19 chest X-ray images that was obtained from the free-to-access
COVID-19 Radiography Database[1]. The system created 5,000 64x64 synthetic
grayscale images, which, when judiciously used as part of training a downstream
ResNet-18 classifier at a ratio of 30% real / 70% synthetic images, improved the test
accuracy from 94.3% to 99.0%, a statistically significant increase of 4.7 percentage
points [2].

This report highlights four key contributions of the completed first phase of
development for Project Phase II, and how those contributions will resolve the
problems, architectural issues, and evaluation deficiencies of the first phase of Project
Phase I . The Progressive GAN will progressively build up your generator's and
discriminator's resolutions from 44x44 to 256x256 over the course of the training
process (by training in 7 steps), with a smooth alpha fade-out of the old resolution[3].

iv
Second, the use of residual discriminator with skip connections and minibatch
standard deviation like in StyleGAN2 [4] help gradients flow and discriminate
between different categories. Third, R1 gradient penalty regularization decreases the
training instability in 8% of total runs down from 23% [5]. Fourth, a multi-metric
evaluation protocol using Frchet Inception Distance (FID) as well as Inception score
(IS), precision recall curve (PRC), and perceptual path length (PPL) are define [6].

Initial outputs at 6464 progressive stage get FID = 38.1 and IS = 6.24, target final FID
< 15 and IS > 8.0 on 256256 resolution. Combined usage of mixed-precision training
and gradient checkpointing drops peak GPU memory usage from theoretically
unusable 28.4GB down to 14.2GB, enabling 256256 training on Tesla T4. Extension
to downstream objective with >=12% gain over real-data-only baselines adds on the
4.7 pp gain obtained in Phase I.
Keywords: Generative Adversarial Networks, Progressive GAN,
StyleGAN2, Medical Image Synthesis, Tumour Histopathology, Fréchet
Inception Distance, Data Augmentation, Transfer Learning, Mixed-
Precision Training.

v
TABLE OF CONTENTS
Introduction ........................................................................................................................................... 1
1.1 Background and Motivation ............................................................................................................ 1
1.2 Project Phase I: Summary and Limitations....................................................................................... 2
1.3 Scope and Research Objectives of Project II .................................................................................... 4
1.4 Report Organisation ........................................................................................................................ 5
2. Theoretical Background..................................................................................................................... 6
2.1 The GAN Minimax Formulation ....................................................................................................... 6
2.2 Wasserstein Distance and R1 Gradient Penalty ............................................................................... 7
2.3 Progressive Growing for Stable High-Resolution Training ................................................................ 8
2.4 StyleGAN2 and Residual Discriminator Design................................................................................. 8
2.5 Transfer Learning and Domain Adaptation ...................................................................................... 9
2.6 Evaluation Metrics: Formal Definitions.......................................................................................... 10
2.6.1 Fréchet Inception Distance (FID) ............................................................................................................. 10
2.6.2 Inception Score (IS)................................................................................................................................. 10
2.6.3 Precision and Recall for Generative Models............................................................................................. 11
2.6.4 Perceptual Path Length (PPL) .................................................................................................................. 11
3. Extended Literature Review ............................................................................................................ 12
3.1 Foundational GAN Research .......................................................................................................... 12
3.2 Training Stability and Regularisation ............................................................................................. 13
3.3 Progressive and High-Resolution Synthesis ................................................................................... 14
3.4 Medical Image Synthesis ............................................................................................................... 14
3.5 Computational Efficiency............................................................................................................... 16
3.6 Evaluation and Quality Assessment ............................................................................................... 17
4. System Architecture ........................................................................................................................ 18
4.1 Overall Architecture and Design Philosophy .................................................................................. 18
4.2 Progressive Generator Specification .............................................................................................. 18
4.3 StyleGAN2 Discriminator Specification .......................................................................................... 20
4.4 Baseline Reference: Project I Architecture..................................................................................... 21
4.5 Progressive Training Schedule ....................................................................................................... 22
4.6 System Workflow .......................................................................................................................... 24
5. Complete Implementation .............................................................................................................. 25
5.1 Environment Initialisation ............................................................................................................. 25
5.2 Dataset Classes.............................................................................................................................. 26

5.3 Project I DCGAN Architecture ........................................................................................................ 27


vi
5.4 Progressive Generator and StyleGAN2 Discriminator .................................................................... 28
5.5 R1 Penalty and Training Loop ........................................................................................................ 30
5.6 Downstream Classifier and FID Module ......................................................................................... 32
6. Experimental Setup ......................................................................................................................... 34
6.1 Hardware Configuration ................................................................................................................ 34
6.2 Dataset Configuration ................................................................................................................... 35
6.3 Hyperparameter Configuration...................................................................................................... 36
7. Results and Validation ..................................................................................................................... 38
7.1 Project I: Training Dynamics and Convergence .............................................................................. 38
7.2 Project I: Downstream Classification Results ................................................................................. 39
7.3 Project II: Preliminary Metrics at 64×64 Stage ............................................................................... 40
7.4 Comprehensive Performance Summary ........................................................................................ 41
7.5 Training Stability and Gradient Analysis ........................................................................................ 42
8. Comparative Evaluation .................................................................................................................. 43
8.1 Comparison with State-of-the-Art ................................................................................................. 43
8.2 Discussion of Comparative Position ............................................................................................... 44
9. Ablation Studies .............................................................................................................................. 45
9.1 Component-Wise Architecture Ablation ........................................................................................ 45
9.2 Hyperparameter Sensitivity Analysis ............................................................................................. 47
9.3 Latent Space and Minibatch Standard Deviation Analysis ............................................................. 48
10. Research Output ........................................................................................................................... 50
10.1 Publication Plan and Timeline ..................................................................................................... 50
10.2 Impact and Relevance ................................................................................................................. 51
11. Conclusion and Future Work ......................................................................................................... 52
11.1 Summary of Contributions........................................................................................................... 52
11.2 Future Research Directions.......................................................................................................... 53
11.2.1 Genuine Tumour Histopathology Integration......................................................................................... 53
11.2.2 Conditional and Class-Guided Synthesis ................................................................................................ 53
11.2.3 Diffusion Model Comparison................................................................................................................. 53
11.2.4 Federated Privacy-Preserving Training .................................................................................................. 54
11.2.5 Self-Attention and Transformer Architectures ....................................................................................... 54
12. References..................................................................................................................................... 55
Appendix A: Risk Register and Mitigation Strategies ........................................................................... 61
Appendix B: Updated Project Timeline................................................................................................ 62

Appendix C: Computational Resource Analysis ................................................................................... 64


Appendix D: Complete Algorithm Pseudocode.................................................................................... 65
D.1 Progressive GAN Training Algorithm .............................................................................................
vii 65
D.2 FID and Downstream Classifier Algorithms ................................................................................... 67

vii
i
LIST OF FIGURES

FIGURE 1 GAN LOSS THEORY – OPTIMAL DISCRIMINATOR CRITICAL POINT (LEFT), WASSERSTEIN VS

BCE LOSS LANDSCAPE (CENTRE), R1 GRADIENT PENALTY EFFECT ON DISCRIMINATOR (RIGHT)

. ............................................................................................................................................. 7

FIGURE 2 PROPOSED SYSTEM ARCHITECTURE – PROGRESSIVE GENERATOR (LEFT), STYLEGAN2

DISCRIMINATOR (CENTRE), AND RESNET-18 DOWNSTREAM CLASSIFIER (RIGHT) WITH

ADVERSARIAL FEEDBACK LOOP .............................................................................................18

FIGURE 3 RESIDUAL BLOCK ARCHITECTURE – CORE BUILDING BLOCK OF STYLEGAN2-INSPIRED

DISCRIMINATOR ....................................................................................................................20

FIGURE 4 PROGRESSIVE GAN TRAINING SCHEDULE – SEVEN RESOLUTION STAGES FROM 4×4 TO

256×256 WITH ITERATION BUDGETS ......................................................................................22

FIGURE 5 COMPLETE SYSTEM WORKFLOW – DATASET ACQUISITION THROUGH DOWNSTREAM

VALIDATION..........................................................................................................................24

FIGURE 6 COVID-19 RADIOGRAPHY DATABASE CLASS DISTRIBUTION (LEFT) AND TRAIN/VAL/TEST

SPLIT FOR CLASSIFICATION (RIGHT) .......................................................................................31

FIGURE 7 TRANSFER LEARNING DUAL PATHWAY – GENERATOR PRE-TRAINING FROM PHASE I (TOP)

AND RESNET-18 ADAPTATION (BOTTOM) ...............................................................................31

FIGURE 8 PROJECT I DCGAN TRAINING LOSS CONVERGENCE OVER 50 EPOCHS (LEFT) AND PROJECT

II FID SCORE PROGRESSION TREND AT 64×64 STAGE (RIGHT).................................................38

FIGURE 9 CONFUSION MATRIX FOR BEST DOWNSTREAM CLASSIFIER – 30-70 BLEND (LEFT) AND PER-

CLASS ACCURACY COMPARISON (RIGHT) ...............................................................................39

ix
FIGURE 10 FID FEATURE SPACE VISUALISATION – HIGH FID DISTRIBUTIONAL GAP AT CURRENT

STAGE (LEFT) VS TARGET LOW-FID TIGHT OVERLAP (RIGHT) ...............................................40

FIGURE 11 PRECISION-RECALL CURVES – DOWNSTREAM CLASSIFIER REAL-ONLY VS 30-70 BLEND

(LEFT) AND GENERATIVE QUALITY-DIVERSITY TRADE-OFF (RIGHT) ......................................41

FIGURE 12 TRAINING TIME BREAKDOWN PER EPOCH – PROJECT I VS PROJECT II (LEFT) AND

ESTIMATED GPU-HOURS PER RESOLUTION STAGE (RIGHT) ....................................................42

FIGURE 13 ABLATION STUDY – FID SCORE (LEFT) AND TRAINING STABILITY (RIGHT) BY

INCREMENTAL ARCHITECTURE ENHANCEMENT.......................................................................45

FIGURE 14 LATENT SPACE SPHERICAL INTERPOLATION – EIGHT STEPS FROM Z₁ TO Z₂

DEMONSTRATING SMOOTH PERCEPTUAL TRANSITIONS ...........................................................48

FIGURE 15 MINIBATCH STANDARD DEVIATION – WITHOUT PENALTY (MODE COLLAPSE, LEFT) VS

WITH PENALTY (DIVERSITY PRESERVED, RIGHT) ....................................................................48

FIGURE 16 INCEPTION SCORE PROGRESSION (LEFT) AND MULTI-METRIC NORMALISED

PERFORMANCE SUMMARY ACROSS ALL DIMENSIONS (RIGHT) ...............................................49

FIGURE 17 : GENERATOR PARAMETER COUNT BY RESOLUTION STAGE (LEFT) AND GPU MEMORY

OPTIMISATION IMPACT BY RESOLUTION (RIGHT) ...................................................................49

x
LIST OF TABLES

TABLE 1 PROGRESSIVE GENERATOR ARCHITECTURE – COMPLETE SEVEN-BLOCK SPECIFICATION . 19

TABLE 2 STYLEGAN2-INSPIRED DISCRIMINATOR – COMPLETE SIX-BLOCK SPECIFICATION .............21

TABLE 3 PROJECT I DCGAN GENERATOR – BASELINE REFERENCE (NZ=100, 64×64 GREYSCALE). 21

TABLE 4 PROJECT I DCGAN DISCRIMINATOR – BASELINE REFERENCE ............................................22

TABLE 5 PROGRESSIVE TRAINING STAGE SCHEDULE WITH RESOURCE ESTIMATES (MIXED

PRECISION)............................................................................................................................23

TABLE 6 SOFTWARE LIBRARY VERSIONS AND DEPENDENCIES ........................................................33

TABLE 7 HARDWARE AND SOFTWARE CONFIGURATION ..................................................................34

TABLE 8 EXPERIMENTAL CONFIGURATION BY TRAINING STAGE ......................................................36

TABLE 9 HYPERPARAMETER CONFIGURATION – PROJECT I VS PROJECT II WITH JUSTIFICATIONS .......37

TABLE 10 PROJECT I DOWNSTREAM CLASSIFICATION ACCURACY BY DATASET CONFIGURATION .....39

TABLE 11 COMPREHENSIVE QUANTITATIVE PERFORMANCE COMPARISON – PROJECT I VS PROJECT II

. ............................................................................................................................................42

TABLE 12 COMPARISON WITH STATE-OF-THE-ART IN MEDICAL AND GENERAL GAN LITERATURE 44

TABLE 13 ABLATION STUDY RESULTS – COMPONENT-WISE FID AND STABILITY IMPACT ................46

TABLE 14 HYPERPARAMETER SENSITIVITY ANALYSIS – R1 PENALTY COEFFICIENT Γ.......................47

TABLE 15 RESEARCH OUTPUT AND DISSEMINATION PLAN ..............................................................50

TABLE 16 RISK REGISTER AND MITIGATION STRATEGIES................................................................62

TABLE 17 UPDATED PROJECT TIMELINE – PHASE II SUMMARY .......................................................63

TABLE 18 COMPUTATIONAL OPTIMISATION TECHNIQUES – MEMORY AND TIME IMPACT AT 256×256

RESOLUTION .........................................................................................................................64

xi
LIST OF ACRONYMS / ABBREVIATIONS
\ Full Form

Adam Adaptive Moment Estimation


API Application Programming Interface
AUC Area Under the Curve
BCE Binary Cross-Entropy
BN Batch Normalisation
CNN Convolutional Neural Network
CUDA Compute Unified Device Architecture
DCGAN Deep Convolutional GAN

DDPM Denoising Diffusion Probabilistic Model


FID Fréchet Inception Distance
FP16 16-bit Floating Point (Half Precision)
FP32 32-bit Floating Point (Single Precision)
GAN Generative Adversarial Network
GPU Graphics Processing Unit
H&E Haematoxylin and Eosin (Histological Stain)
IS Inception Score
LR Learning Rate
MRI Magnetic Resonance Imaging
PPL Perceptual Path Length
PR Precision-Recall

xii
Introduction

1.1 Background and Motivation


Pathology identification from medical images remains one of the most impactful and
actively researched application areas of AI in medicine. Well annotated large image
databases have enabled deep convolutional networks to perform as well as board-
certified clinicians in limited tasks such as pneumonia detection from chest X-rays,
retinopathy grading from fundus photographs and classification of skin lesions from
dermoscopic images [7]. But the critical prerequisite for such good results i.e. Large,
balanced and expertly annotated image training databases does not exist in a clinical
scenario.
The inherent structural limitations facing medical imaging datasets, which
differentiate them strongly from natural image data sets, are many. Regulations
concerning patient consent make it difficult or impossible to pool data across
institutions and even countries. Expertise needed for clinical annotation, along with
the time it takes, is expensive and time-consuming. An abundance of rare diseases
guarantees an extreme class imbalance of few positive examples. The variety of
scanner manufacturers, protocol settings and imaging sites create unavoidable domain
shifts that degrade a trained models performance. These limitations make methods of
generating synthetic data that supplement training data without the need for extra
clinical scans an attractive research problem [8].
Since their introduction by Goodfellow et al. In their seminal 2014 paper [9],
Generative Adversarial Networks (GANs) are arguably the most investigated and
practically successful method for high-fidelity synthetic image synthesis. The training
procedure consists of placing the generator network (which maps a random latent code
to a synthetic image) in opposition to the discriminator network, which tries to tell
apart synthetic from real images. Through competition the generator must produce
ever more realistic samples. At theoretical convergence to a Nash equilibrium, the
generator has completely learned the statistics of the training data and is capable of
producing infinite novel photorealistic samples on demand. Over the past ten years

Page | 1
the GAN research community has developed a whole ecosystem of architectural
improvements, regularization methods, and objective metrics, aiming at overcoming
the numerous failure modes of the original method: mode collapsing, non-
convergence of the training procedure and unreliable perceptual quality metrics [10].
The context of this work is a blend of modern GAN approach and its application to
medical image synthesis. Our global objective is the development of a production
quality, modular system that is designed to generate high resolution tumour
histopathology images which is technically sound, empirically evaluated and also
feasible within a resource constraint academia lab setting. By incrementally pushing
the limits in resolution and architectural complexity, and developing a multi-metric
framework for evaluating the system, this project hopes to form a link between state-
of-the-art GAN research and medical data augmentation.
The social relevance of this work goes further than the problem technical one.
Pathology image analysis, especially the cancer diagnostics applications, are domains
where lack of data has a direct influence on patient outcome. Histopathology is the
reference standard for cancer diagnosis and annotated digital whole-slide images rely
on expensive and rare expert knowledge. A confirmed method of artificial
histopathology data augmentation that alleviates annotation workload and allows for
effective growth of dataset size is directly applicable to clinical work.

1.2 Project Phase I: Summary and Limitations


Project Phase I was completed in the previous semester. This phase developed a proof
of concept of using GANs to augment data in the scope of classification of chest X-
ray images into the COVID-19 positive category. 3616 chest X-ray images classified
as COVID-19 positive from Chowdhury et al. [1]'s COVID-19 Radiography Database
were used and trained on a DCGAN architecture inspired by Radford et al. [11]. A
latent vector of 100 dimensions consisting of random values were mapped to a 6464
greyscale image by 5 stages of transposed-convolution with batch normalisation and
ReLU activation layers in the generator. The discriminator implemented binary
classification, real/fake by use of 5 stages of strided convolution with LeakyReLU
activation functions followed by a final sigmoid layer.

Page | 2
With an Adam optimiser and settings of 0.0002 and 0.5 for learning rate and
momentum coefficient respectively after 50 epochs of training the models converged
well and produces visually reasonable chest X-ray images. Domain experts judged
that the generated images were biologically plausible. A subsequent classification
experiment shows that adding 5000 synthetic images with a training ratio of 30% real
and 70% synthetic raised ResNet-18 test accuracy from 94.3% to 99.0% which
compared well with the latest published systems that classify COVID-19 images [2].
The total training time on the Tesla T4 GPU was about 10 hours.
In addition to these positive findings, there were 5 limitations which led to Phase II
extension:. First, a resolution of 6464 pixels is intrinsically incapable of providing
analysis for tumour histopathology; subcellular morphology features like nuclear
pleomorphism, mitotic figures, and glandular architecture need 256256 pixels and
above to be of clinical value. The simple, unadorned DCGAN does not use state-of-
the-art stabilisation methods as seen in the 23% early-stop rate due to imbalance in
generator-discriminator performance. Assessment used a single proxy measure of
performance (accuracy on downstream task) as opposed to measures of perceptual
quality calibrated on the real image distribution. Furthermore, its single-modality,
single-resolution setup is a direct constraint on clinical utility and also on the
generalisability of its methodological contribution. Lastly, the pipeline lacks
optimisation to handle the computational needs of larger resolutions on the current
hardware..

Page | 3
1.3 Scope and Research Objectives of Project II
This second phase works on each of the aforementioned issues in a coherent,
architectural, experimental, analytical and operational, way to reach a total of five
formal research goals:

1. O1 - High resolution synthesis frame: Synthesize 256x256 RGB tumour


histopathology images using a Progressive GAN that dynamically grows its
resolution from 4x4 during seven distinct training steps. Smooth alpha
transitions are implemented[3].
2. O2 - Enhanced architectural configuration: Substitute the Phase I discriminator
with a residual network inspired on StyleGAN2 with skip connections,
minibatch standard deviation and R1 gradient penalty to stabilize training and
quality generation [4,5].
3. O3 - Comprehensive framework for analysis: Define a standard to evaluate the
generated images using combined Frchet Inception Distance and Inception
Score, PR decomposition and Perceptual Path Length for comparison with
existent methods[6].
4. O4 - Downstream applicability verification: Demonstrate that synthetic images
can be effectively utilized for downstream ResNet-18 classification at a
minimum 12% improvement compared to real-data-only models, a step up from
the 4.7pp gain seen in phase I.
5. O5 - computational costs optimization: Stay within the constraints of a 16GB
Tesla T4 card using mixed precision arithmetic, gradient checkpointing and
adaptive minibatch sizing [28,29].

Page | 4
1.4 Report Organisation
This rest of the report follows this structure. In chapter 2, the theoretical
framework will be introduced, and this section covers GAN formulation,
progressive training method, the contributions in StyleGAN2, transfer
learning principles and the derivation of evaluation metrics. In chapter 3, a
comprehensive review on literature is presented, the subtopics of GAN are
presented based on foundations of GAN, high-resolution image generation,
medical image applications, various regularization schemes, work in terms
of computational costs and how the final evaluation metric is derived.
Chapter 4 introduces the entire extended system architecture, including
specifications of Progressive Generator, StyleGAN2 Discriminator, and
downstream classifier. In chapter 5, the full implementation is described
and sample code snippets from the project notebook are included with
explanations. Chapter 6, experiment setup, the choice of data, hardware
resources will be explained. Chapter 7, presents and analyzes the findings
and validations from the experiments. In chapter 8, compares the approach
with state-of-the-art techniques. Chapter 9, ablated studies are carried out
to demonstrate the effectiveness of each module. Chapter 10 discusses
about research output and the plan for dissemination of research. Chapter
11 concludes the report and presents potential future work. The reference
list is presented in chapter 12. Finally, Appendices includes risk register,
timeline of the project, computational analysis of efficiency and algorithm
pseudocode.

Page | 5
2. Theoretical Background

2.1 The GAN Minimax Formulation


GAN's setup: A two-player, zero-sum game between the generator G and the
discriminator D, where both G and D are parameterized as differentiable neural
networks. G : Z X maps samples from a predefined prior p z(z) (usually from isotropic
Gaussian distribution or uniform over a compact interval) to data space X. D : X [0,1]
maps from data to the probability that the data is from real data distribution p data(x)
instead of the generator distribution p g(x). The default minimax value function
introduced by Goodfellow et al. [9] is:

V(G, D) = E_{x ~ p_data(x)} [log D(x)] + E_{z ~ p_z(z)} [log(1 − D(G(z))))

The discriminator maximises V with respect to its parameters, while the generator
minimises V with respect to its own parameters. Goodfellow et al. proved that, for any
fixed generator G, the optimal discriminator is D*(x) = p_data(x) / [p_data(x) +
p_g(x)]. Substituting this optimal discriminator back into V yields the global objective
C(G) = −log(4) + 2 · JSD(p_data || p_g), where JSD denotes the Jensen-Shannon
divergence. The global minimum is achieved when p_g = p_data, at which point D*(x)
= 1/2 everywhere and C(G) = −log(4).

Another practical problem that has proved very important is that if the true distribution
and generated distribution have disjoint supports, the discriminator can learn perfectly
early in the training, and hence JS divergence will plateau at log(2), causing the
generator gradient to become zero. The common way to avoid this in practice is to use
the non-saturating generator loss, LG = E{z~p_z}[log D(G(z))], so that the objective
of the generator is to maximise the probability of getting a high score from the
discriminator for fake samples instead of minimising the probability of getting a low
score.

Page | 6
Figure 1 GAN Loss Theory – Optimal Discriminator Critical Point (Left), Wasserstein vs BCE Loss Landscape (Centre), R1 Gradient
Penalty Effect on Discriminator (Right)

2.2 Wasserstein Distance and R1 Gradient Penalty


Arjovsky, Chintala and Bottou [12] demonstrated that Jensen-Shannon divergence is
a poor distance measure for training GANs when the supports of real and generated
distribution are disjoint-which is true almost everywhere in high dimensional spaces
and especially during the beginning of training. They thus replaced the Jensen-
Shannon divergence by Earth Mover (Wasserstein-1) distance W (p,q) = inf{ (p,q)}
E{(x,y)~}[||x y||] to form the objective function and WGAN where the discriminator
function is replaced by a critic functionf with a 1-Lipschitz constraint.

Weight clipping which the original WGAN used to enforced Lipschtz continuity.
Gulrajani et al. [5] proved that this had pathological gradient dynamics and suggested
the use of a gradient penalty, or GP, to enforceLipschitiz continuity in a more principle
manner: E{x}[(||{x} D(x)|| 1)], where x is a uniform sample along straight lines
connecting real data points and generated samples. Mescheder, Geiger and Nowozin
[13] showed that applying zero centred gradient penalty on real data points only (R1
regularisation scheme) gives guarantees for convergence under weak assumption and
showed it was more empirically stable: R = (/2) E{x~pdata}[||_x D(x)||]. R
discourages the discriminator to have large gradient at real data points. In Project II
=10.0 was used, based on recommendation in [13].

Page | 7
2.3 Progressive Growing for Stable High-Resolution Training
To alleviate the difficulty of training GANs at high resolution, the progressive
growing paradigm was proposed by Karras, Aila, Laine and Lehtinen [3]. The basic
idea is to approximate learning the full joint distribution over a high-resolution image
by a sequence of training: first learn a distribution of global coarse structure at low
resolution, then incrementally add details of higher frequency at a sequence of
resolutions. Such hierarchical learning is inspired by the multi-scale structure of
natural images and is well consistent with the property of neural network
representation, which represents low-frequency information in earlier layers and high-
frequency details in later layers.
The fade-in mechanism enables smooth transitions between resolution stages without
abrupt perturbations to the training dynamics. When transitioning from resolution R
to 2R, the new higher-resolution generator output x_{2R} is blended with a bilinearly
upsampled version of the previous-stage output x_R via a linearly increasing
coefficient α: x_blend = α · x_{2R} + (1−α) · upsample(x_R). At α = 0 the new block
has zero effect; at α = 1 it is fully incorporated. The gradual increase over several
thousand iterations prevents the sudden loss spikes at stage boundaries that would
otherwise cause training collapse.

2.4 StyleGAN2 and Residual Discriminator Design


Architecture Quality: The StyleGAN2 architecture developed by Karras et al. [4]
detected and fixed many quality artefacts systematic to the original StyleGAN. Of the
StyleGAN2 contributions, the discriminator modifications are the most relevant to
Project II. Instead of using a regular convolutional discriminator, the StyleGAN2
discriminator uses a residual network architecture with both skip connections, which
combine features from several different scales, and residual connections within the
blocks, to avoid the problem of vanishing gradients in very deep networks. Finally,
the minibatch standard deviation layer is added just before the final classification,

Page | 8
outputting one feature map with a single value, the average per pixel std dev for that
minibatch. This can be used as an indicator of mode collapse; all the real samples will
have varied activation levels, while the samples in a batch of generated samples would
ideally be similar to each other (as each is the result of one particular mapping) and
have a very small std dev.
AdaIN, the module that injects style into StyleGAN generator, normalises feature
maps at each location to 0 mean and 1 variance and scales/biases with learned per-
channel scale and bias from learned transformation of latent code. Such an explicit
injection module is key for separating control over structure (coarse latent codes) and
details (fine latent codes). While Project II re-uses the improvements of discriminator
in StyleGAN2, the architecture of generator is kept to progressive convolution layer
described by Karras et al [3], which can be more directly implemented without style
mapping network.

2.5 Transfer Learning and Domain Adaptation


Transfer learning is built on the premise that feature representations learned by deep
networks on a large data set capture generic visual primitives which can be transferred
to other related domains [14]. The authors showed empirically that ImageNet-trained
CNN layers with low depth learned feature representations that were domain-invariant
(e.g., edges, textures, color gradients) and transferred very well to various visual
domains, and that features learned in deeper layers of the network are domain-specific.
By fine-tuning an ImageNet pre-trained CNN to the target domain, the models achieve
faster convergence and achieve better performance compared to randomly initialized
network.
Transfer learning, however, has not been investigated as extensively in the context of
GANs as in discriminative tasks. Karras et al. [3] showed progressive training to be
implicitly a form of curriculum learning-transfer where low-resolution stages pre-train
the network on a coarse variant of the task before higher resolutions are introduced.
Project II draws on these two aspects: Phase I DCGAN weights are used as the
initialization for the Phase II 6464 stage which enables the transfer of low-level visual

Page | 9
features from the COVID X-ray domain, and ImageNet-pretrained ResNet-18 is used
as the initialization for the downstream classifier, facilitating the transfer of a general
visual feature extractor..

2.6 Evaluation Metrics: Formal Definitions

2.6.1 Fréchet Inception Distance (FID)


The FID [6] is calculated by extracting 2048-dimensional feature vectors f(x) from
the pool3 layer of pre-trained Inception-v3 network both on a set of real image Xr and
synthesized images Xg, and approximating the feature distributions as multivariate
Gaussians N(r, r) and N(g, g). The distance is the Fréchet (Wasserstein-2) distance
between the two Gaussians:

The first term accounts for mean feature shift (quality) and second term accounts for
discrepancy in covariance (diversity). FID is presently the most popular automatic
measure and has shown best correspondence with human perceptual scores among all
existing automatic metrics [30].

2.6.2 Inception Score (IS)


The Inception Score [17] assesses sharpness and diversity through the label
distributions over the Inception-v3 classifier. High Inception Score means the
classifier outputs images that are sharp (low entropy on conditional y given x) and
also diverse over the classes (high entropy on marginaly). We want IS to be as high
as possible for the best result [18] but in combination with FID score as well.

Page | 10
2.6.3 Precision and Recall for Generative Models
Formalized Precision-Recall decomposition for generative models was developed by
Kynknniemi et al. [19] based on k-NN manifold estimation in Inception-v3 feature
space. The real manifold Mr was estimated as union of k-NN balls with centers at real
feature vectors and generated manifold Mg in the same way. Then Precision = |{xg :
f(xg) Mr}| / |Xg| is the fraction of images from Xg falling into support of real data,
and Recall = |{xr : f(xr) Mg}| / |X_r| is the fraction of real data covered by the model.
Precision and Recall can also be decomposed for single attributes [19]. A model with
high Precision and low Recall mode-collapse, i.e., it generates samples with high
fidelity but diversity of generated samples is lacking, whereas a model with high
Recall and low Precision generates diverse samples but the fidelity is low.

2.6.4 Perceptual Path Length (PPL)


The smoothness of the latent-to-image map is also captured by PPL [4] where it is
defined as the expectation of perceptual distance between images generated from
perturbed latent code pair (slerping between latent vectors). Specifically for spherical
interpolation it is, PPL full = E z,z,t [(1/)d(G(slerp(z,z,t)), G(slerp(z,z,t+)))], where
slerp is spherical linear interpolation, is a tiny perturbation,t [0,1]and d(,) is the LPIPS
perceptual distance. Lower PPL corresponds to a more organized, disentangled and
smooth latent space where a small change in latent input would results in proportional
changes in the generated image perception; higher PPL indicates rapid changes in
perceptual quality for an interpolation over latent vectors, a failure for organizing
latent code.

Page | 11
3. Extended Literature Review

3.1 Foundational GAN Research


In their original formulation Goodfellow et al. [9] applied GANs to generate low
resolution images of simple datasets such as handwritten digits and small CIFAR
images. A stable way of training high resolution natural image generators was
proposed by Radford, Metz, and Chintala [11] with their framework known as
DCGAN. By removing the fully connected layers, using strided convolutions, no
pooling, batch normalisation in both networks and a careful selection of activation
functions (ReLU for the generator and LeakyReLU for the discriminator), they
showed that a 64×64 image generator could be trained stably on face, bedroom, and
street-view data. Their hyperparameter choice (Adam at learning rate 0.0002, and with
a choice of = 0.5) become standard; it was directly used in Project I and as a starting
point for Project II.
Isola et al. [34] presented a conditional image-to-image translation framework
(pix2pix) and successfully demonstrated that a conditioned GAN can learn an image-
to-image translation task for many different data domains; these range from semantic
segmentation to photograph synthesis, aerial photography to map conversion, and
edges to photographs. The patch discriminator proposed by Isola et al. [34] (which
classifies image patches instead of the whole image) worked particularly well for
retaining high frequency textural information in generated images. This work
influenced the development of subsequent medical image synthesis techniques, as
well as the design philosophy of a multi-scale discriminator, which we adopted in
Project II.

Page | 12
3.2 Training Stability and Regularisation
Training instability of GAN was analyzed theoretically by Arjovsky et al [12] who
showed that the original GAN loss is equivalent to minimising a Jensen-Shannon
divergence which degenerates to be uninformative when real and fake distributions
are disjoint in support. Wasserstein GAN [9] was developed with Earth Mover
distance using Lipschitz-constrained critic. Improved on WGAN with gradient
penalty, Gulrajani et al [5] suggests that it is optimal to constrain the critic function
by Lipschitz condition on the interpolations between real and fake samples rather than
weight clipping. R1 regularisation was proposed by Mescheder et al [13] as a simpler
variant in which only the real data gradients are penalised, while providing strong
theoretical guarantees, reducing the computational cost.

An alternative approach on Lipschitz constraint was suggested by Miyato et al [22]


who normalize the weight matrices of discriminator layers by their spectral norm,
which is called spectral normalization. Spectral normalization is negligibly costly and
doesn't require computing second-order derivatives as opposed to gradient penalty,
and has become a part of standard GAN discriminators in production. Spectral
normalization was considered as an alternative to R1 regularisation for Project II, but
R1 was selected for its higher convergence guarantees.

Zhao et al. [27] studied the importance of differentiable data augmentation for GAN
training. They found that when augmentation is applied to both real and generated
images prior to the discriminator's evaluation it improves efficiency of training data
and stability. This improvement is significantly noticeable in the low data domain.
Methods such as random horizontal flipping, color jittering and random cropping
implemented via differentiability in order to maintain real/fake signal of discriminator
and expose to varied appearance of image are very important especially in medical

Page | 13
images since amount of available data is limited. We thought this method will fit into
Project II training setup in a natural way.

3.3 Progressive and High-Resolution Synthesis


First GAN to train 1024x1024 faces with reasonable FID (8.04 compared to 36.4 for
standard GAN training) using Karras et al.'s progressive training method [3]. The
authors show much evidence that this improvement is due to progressive training and
not increased model capacity; showing its crucial need for hierarchical curriculum
training. It also implemented some techniques (minibatch standard deviation,
equalized learning rates, pixelwise feature normalization) which improve training
stability.

Demonstrates the behavior of conditional GANs when trained at massive scale.


Showed how class conditional GANs trained up to 158 million parameters and 2048
batch sizes on clusters of 512TPUs could achieve Inception scores over 300 and FID
below 7 for 512x512 ImageNet models. Though unattainable at an academic scale,
the conditional GAN incorporates architectural details such as self-attention and
weight orthogonalization which have been successfully used in smaller networks.

The VQGAN architecture by Esser et al. [32], on which we base our model, combines
an autoencoder using vector-quantisation and a GAN discriminator to achieve a highly
compressed discrete codebook representation of an image that supports both good
reconstruction and a feasible generator. VQGAN based methods have been of great
importance in conditional image synthesis and can be used as a perceptual quality
network in latent diffusion models. Codebook compression appears a feasible design
addition for high resolution medical image synthesis when computation is constrained.

3.4 Medical Image Synthesis


The use of GANs in medical imaging has inspired a significant amount of research
over a range of modalities. GANs have been used for liver lesion CT augmentation
[8] where they achieved roughly 7% boost in CNN classification performance, which

Page | 14
showed that generated medical images were able to give an effective training [Link]
et al. [20] conducted a systematic review on 52 studies of GAN-based medical
augmentation, where the average improvement across modalities and pathologies was
8.2% on downstream classification with significantly greater increases in areas with
lower amounts of training data.

The researchers use CycleGAN [35] to perform unpaired cross-modal translation


between CT and MRI and indicate that the synthesized cross-modal images are
capable of replacing the ground-truth paired training data to train an organ
segmentation network, withDice similarity coefficients within 5% of real-data
baselines. It clearly indicated the ability of GAN based synthesis to lessen the burden
of collecting multi-modal medical imaging data.

Zhao et al. [24] use the Progressive GAN for the generation of retinal fundus image
data for the purpose of augmenting diabetic retinopathy (DR) classification and
achieved FID of 22.4 for 256x256 image resolution, while improving classification
on a downstream DR classifier by 9%. The closest published analogue of project II,
this demonstrates direct empirical justification for the use of progressively trained
generation in the medical image modality. The difference inFID value 22.4 reported
by them and project II goal value <15 represents the benefit provided by further
StyleGAN2 discriminator enhancements and R1 regularisation..

This is directly motivated by the intention to apply Project II to real histopathology


data in the future (from the TCGA data repository) which are H&E stained breast
cancer images, and where conditioning on magnification level and pathology class
would provide clinically relevant synthesis [25]. They used a ResNet-50 downstream
classifier and were able to decrease misclassification rate by 14% compared to real
data only training ( at 256x256 resolution) when conditioned on magnification and
class.

Page | 15
Nie et al [26] adapted GAN-based medical image synthesis into 3D volumetric MR-
to-CT translation using a 3D Fully Convolutional GAN. Although the current project
works in 2D patch synthesis, the principle is directly applicable and the adaptation of
progressive training into 3D is a practically useful, but computationally intensive,
future possibility for the planning phase of surgery..

3.5 Computational Efficiency


The significant training costs associated with high-resolution GAN training was one
of the key factors driving research into several methods which form the core of the
implementation strategy for Project II. Micikevicius et al. [28] describes the mixed-
precision training method. This method makes use of the FP16 arithmetic units in
NVIDIA Volta and newer GPUs in order to cut down both memory usage and
computation latency. The master weights are stored in FP32 and the forward and
backward passes are performed using FP16 operations (a loss scaling mechanism is
used to prevent the gradients from underflowing due to the use of reduced-precision
arithmetic). From experimental results reported, mixed-precision training yields about
a 50% saving in memory and speeds up training by 2 to 3 times on Volta architecture
cards..

Gradient checkpointing [29] sacrifices computation to save memory. Intermediate


activations are dropped in the forward pass and re-computed in the backward pass. If
the network has n layers, O(n) memory is needed to store activations in naive training.
Gradient checkpointing saves this to O(n) by splitting the network into n blocks,
storing only the boundary activations and re-computing the interior activations in the
backward pass from the closest stored activation. The additional cost of the re-

Page | 16
computation is roughly 1 additional forward pass (a 33% increase in computation),
which is a good trade-off if memory is the constraint..

3.6 Evaluation and Quality Assessment


One of the core methodological issues in evaluating generative models is that, in
contrast to discriminative models, they cannot simply be assessed using test-set
accuracy, and human visual quality evaluation does not scale to ranking thousands of
generated images. Borji [30] performed an exhaustive survey of over 24 metrics that
have been proposed for evaluation of GANs and determined that among the existing
metrics, FID shows the strongest correlation with human judgments of perceptual
quality and that FID is also computationally tractable. His survey points out that the
FID measure depends on the number of samples taken from the model distribution
when estimating distributions, and suggest a minimum sample size of 10,000 for
stable estimates.

Barratt and Sharma [18] point out some of the failure modes of IS including sensitivity
to the ImageNet pre-training domain of the Inception network used for computing it,
it does not capture models that have overfit on the training set, and IS can be high for
completely unrealistic but confidently classified images. Because of these issues IS
should not be used alone, but in conjunction with FID. Kynknniemi et al. [19]'s
Precision-Recall decomposition explicitly separates quality (Precision) and diversity
(Recall), addressing some of these failure modes, and providing a more diagnostic
picture of the behaviour of generative models.

Page | 17
4. System Architecture

4.1 Overall Architecture and Design Philosophy


The full Project II system is based on three inter-operating parts; the progressive
generator G, the StyleGAN2-like discriminator D and the ResNet-18 downstream
classifier C. All three parts work together on two consecutive steps; the adversarial
training of G-D through seven progressive resolutions and the standalone training of
C on hybrid real-fake data. In purpose the system is modular, meaning each
improvement may or may not be active, the resolution level can be manipulated
through an integer parameter, and can return to the Project I basic model.

Figure 2 Proposed System Architecture – Progressive Generator (Left), StyleGAN2 Discriminator (Centre), and ResNet-18
Downstream Classifier (Right) with Adversarial Feedback Loop

4.2 Progressive Generator Specification


A 512 dimensional vector of Gaussian noise passes through seven transposed-
convolution blocks. The initial block applies a 411 transposed convolution, increasing
a scalar spatial map to a 512 channel 44 feature map. The subsequent 6 blocks use 44
transposed convolutions with stride 2, and padding 1. Each layer uses a series in
Page | 18
geometric progression, increasing the spatial dimensions by factors of two, and
halving the channel count. Batch normalization, and ReLU activations are applied at
intermediate stage block, and the final stage outputs a three channel RGB image after
applying Tanh, to normalize the values in [ -1,1].

Chan
Input Output nels Activat
Block Operation
Shape Shape In→O ion
ut
[B,512,1,1 [B,512,4,4 512→ ConvT2d(512,512,4,
1 (4×4) ReLU
] ] 512 1,0)+BN
[B,512,4,4 [B,512,8,8 512→ ConvT2d(512,512,4,
2 (8×8) ReLU
] ] 512 2,1)+BN
3
[B,512,8,8 [B,256,16, 512→ ConvT2d(512,256,4,
(16×16 ReLU
] 16] 256 2,1)+BN
)
4
[B,256,16, [B,128,32, 256→ ConvT2d(256,128,4,
(32×32 ReLU
16] 32] 128 2,1)+BN
)

5
[B,128,32, [B,64,64,64 128→ ConvT2d(128,64,4,2
(64×64 ReLU
32] ] 64 ,1)+BN
)
6
[B,64,64,6 [B,32,128, 64→3 ConvT2d(64,32,4,2,
(128×1 ReLU
4] 128] 2 1)+BN
28)
7
[B,32,128, [B,3,256,2
(256×2 32→3 ConvT2d(32,3,4,2,1) Tanh
128] 56]
56)
Table 1Progressive Generator Architecture – Complete Seven-Block Specification

Page | 19
4.3 StyleGAN2 Discriminator Specification
The discriminator takes a 256x256 RGB three-channel input and uses a symmetrical
reverse-progressive path. A strided convolution in the first block decreases spatial
resolution. The four middle blocks uses ResidualBlock components-with 2 3x3
convolutions, batch norm, Leaky ReLU and skip connection-, where the spatial
downsampling is achieved by average pooling. A minibatch standard deviation layer
is used in the path to the final prediction block, and a single channel standard deviation
map is added to the feature tensor. In the last block two convolutions are used to
decrease the feature map down to a real/fake prediction (a single real number).

Figure 3 Residual Block Architecture – Core Building Block of StyleGAN2-Inspired Discriminator

Input Output Activatio


Block Operation
Shape Shape n
1
[B,3,256 [B,64,12 LeakyRe
(256→ Conv2d(3,64,3,2,1)
,256] 8,128] LU(0.2)
128)
2
[B,64,12 [B,128,6 ResidualBlock(64,128)+AvgPoo LeakyRe
(128→
8,128] 4,64] l LU(0.2)
64)

Page | 20
3
[B,128,6 [B,256,3 ResidualBlock(128,256)+AvgPo LeakyRe
(64→3
4,64] 2,32] ol LU(0.2)
2)
4
[B,256,3 [B,512,1 ResidualBlock(256,512)+AvgPo LeakyRe
(32→1
2,32] 6,16] ol LU(0.2)
6)

5
[B,512,1 [B,512,8 ResidualBlock(512,512)+AvgPo LeakyRe
(16→8
6,16] ,8] ol LU(0.2)
)
6 [B,512+ MinibatchStdDev→Conv(513,5
[B,1] Sigmoid
(Final) 1,8,8] 12,3)→Conv(512,1,4)
Table 2 StyleGAN2-Inspired Discriminator – Complete Six-Block Specification

4.4 Baseline Reference: Project I Architecture

Laye Kern Strid Pa


Input Output Activation
r el e d
BatchNorm+Re
1 [B,100,1,1] [B,512,4,4] 4 1 0
LU
BatchNorm+Re
2 [B,512,4,4] [B,256,8,8] 4 2 1
LU
[B,128,16,1 BatchNorm+Re
3 [B,256,8,8] 4 2 1
6] LU
[B,128,16,1 [B,64,32,32 BatchNorm+Re
4 4 2 1
6] ] LU
[B,64,32,32
5 [B,1,64,64] 4 2 1 Tanh
]
Table 3 Project I DCGAN Generator – Baseline Reference (nz=100, 64×64 greyscale)

Page | 21
Laye Kern Strid Pa
Input Output Activation
r el e d
[B,64,32,3
1 [B,1,64,64] 4 2 1 LeakyReLU(0.2)
2]
[B,64,32,3 [B,128,16, BN+LeakyReLU(
2 4 2 1
2] 16] 0.2)
[B,128,16, BN+LeakyReLU(
3 [B,256,8,8] 4 2 1
16] 0.2)
BN+LeakyReLU(
4 [B,256,8,8] [B,512,4,4] 4 2 1
0.2)
5 [B,512,4,4] [B,1] 4 1 0 Sigmoid
Table 4 Project I DCGAN Discriminator – Baseline Reference

4.5 Progressive Training Schedule

Figure 4 Progressive GAN Training Schedule – Seven Resolution Stages from 4×4 to 256×256 with Iteration Budgets

Page | 22
Fade-
Stabilise Total Batch VRAM
Stage Resolution In
Iters Iters Size (est.)
Iters

1 4×4 2,000 8,000 10,000 64 0.8 GB

2 8×8 2,000 8,000 10,000 64 1.1 GB

3 16×16 2,500 7,500 10,000 64 1.8 GB

4 32×32 2,500 7,500 10,000 32 3.2 GB

5 64×64 3,000 7,000 10,000 32 5.8 GB

6 128×128 5,000 10,000 15,000 16 9.4 GB

7 256×256 8,000 12,000 20,000 16 14.2 GB

Table 5 Progressive Training Stage Schedule with Resource Estimates (Mixed Precision)

Page | 23
4.6 System Workflow

Figure 5 Complete System Workflow – Dataset Acquisition through Downstream Validation

Page | 24
5. Complete Implementation

5.1 Environment Initialisation


Training and testing were performed on Google Colab Pro with a Tesla T4 GPU (16
GB GDDR6 VRAM). The environment comprises PyTorch 2.1.0 compiled against
CUDA 12.1 with TorchVision 0.16.0 for access to pre-trained models, SciPy 1.11.0
to compute covariance for FID, and Weights and Biases 0.15.0 for monitoring. The
environment initialization sets up Kaggle API keys and checks for the availability of
a GPU:
# Cell 1 – Kaggle API authentication and GPU verification
import json, os, torch, [Link] as nn
import [Link] as F
from [Link] import Dataset, DataLoader
from torchvision import transforms, models
from [Link] import ResNet18_Weights
from PIL import Image

KAGGLE_TOKEN = 'KGAT_5e47bb9f57a236d37adbd4e97e595c68'
[Link]('/root/.kaggle', exist_ok=True)
with open('/root/.kaggle/[Link]', 'w') as f:
[Link]({'username': 'sparsh davra', 'key': KAGGLE_TOKEN}, f)
[Link]('/root/.kaggle/[Link]', 0o600)

device = [Link]('cuda' if [Link].is_available() else 'cpu')


if [Link] == 'cuda':
props = [Link].get_device_properties(0)
print(f'GPU: {[Link]} | VRAM: {props.total_memory/1e9:.1f} GB')
else:
print('WARNING: No GPU detected. Training will be extremely slow.')

Page | 25
5.2 Dataset Classes
The COVIDXRayDataset can use all 4 categories of radiographs. The limits per class
can be defined. The Lung256Dataset performs the bilinear upscaling to 256256, and
the three-channel repetition. Both use the PyTorch Dataset interface (with a len and a
getitem):

# Cell 3 – COVIDXRayDataset (Project I and Phase II 64×64 stage)


class COVIDXRayDataset(Dataset):
def init (self, root_dir, transform=None, max_samples=10000):
[Link], [Link] = [], []
classes = ['COVID','Lung_Opacity','Normal','Viral Pneumonia']
per_cls = max_samples // len(classes)
for idx, cls in enumerate(classes):
path = [Link](root_dir, cls, 'images')
if not [Link](path): continue
for f in [Link](path)[:per_cls]:
[Link]([Link](path, f))
[Link](idx)
[Link] = transform or [Link]([
[Link]((64,64)), [Link](),
[Link](),
[Link]([0.5],[0.5])])

def len (self): return len([Link])


def getitem (self, idx):
return [Link]([Link]([Link][idx])), [Link][idx]

# Cell 4 – Lung256Dataset (Phase II 256×256 stage)


class Lung256Dataset(Dataset):
def init (self, root_dir, max_per_class=4000):
[Link], [Link] = [], []
classes = ['COVID','Lung_Opacity','Normal','Viral Pneumonia']
for idx, cls in enumerate(classes):
path = [Link](root_dir, cls, 'images')
if not [Link](path): continue

Page | 26
for f in [Link](path)[:max_per_class]:
[Link]([Link](path, f))
[Link](idx)
[Link] = [Link]([
[Link]((256,256)),
[Link](num_output_channels=3),
[Link](),
[Link]([0.5,0.5,0.5],[0.5,0.5,0.5])])

def len (self): return len([Link])


def getitem (self, idx):
return [Link]([Link]([Link][idx])), [Link][idx]

5.3 Project I DCGAN Architecture


# Cell 5 – Project I DCGAN Generator (baseline)
class COVIDGenerator([Link]):
def init (self, nz=100, ngf=64, nc=1):
super(). init ()
[Link] = [Link](
nn.ConvTranspose2d(nz, ngf*8, 4, 1, 0, bias=False),
nn.BatchNorm2d(ngf*8), [Link](True),
nn.ConvTranspose2d(ngf*8, ngf*4, 4, 2, 1, bias=False),
nn.BatchNorm2d(ngf*4), [Link](True),
nn.ConvTranspose2d(ngf*4, ngf*2, 4, 2, 1, bias=False),
nn.BatchNorm2d(ngf*2), [Link](True),
nn.ConvTranspose2d(ngf*2, ngf, 4, 2, 1, bias=False),
nn.BatchNorm2d(ngf), [Link](True),
nn.ConvTranspose2d(ngf, nc, 4, 2, 1, bias=False), [Link]())
def forward(self, x): return [Link](x)

class COVIDDiscriminator([Link]):
def init (self, nc=1, ndf=64):
super(). init ()
[Link] = [Link](
nn.Conv2d(nc, ndf, 4, 2, 1, bias=False), [Link](0.2,True),

Page | 27
nn.Conv2d(ndf, ndf*2, 4, 2, 1, bias=False),
nn.BatchNorm2d(ndf*2), [Link](0.2, True),
nn.Conv2d(ndf*2, ndf*4, 4, 2, 1, bias=False),
nn.BatchNorm2d(ndf*4), [Link](0.2, True),
nn.Conv2d(ndf*4, ndf*8, 4, 2, 1, bias=False),
nn.BatchNorm2d(ndf*8), [Link](0.2, True),
nn.Conv2d(ndf*8, 1, 4, 1, 0, bias=False), [Link]())
def forward(self, x): return [Link](x).view(-1)

5.4 Progressive Generator and StyleGAN2 Discriminator


# Cell 16 – Progressive Generator
class FixedProgressiveGenerator([Link]):
def init (self, nz=512):
super(). init ()
[Link] = [Link]([

[Link](nn.ConvTranspose2d(nz,512,4,1,0),nn.BatchNorm2d(512),[Link]
LU(True)),

[Link](nn.ConvTranspose2d(512,512,4,2,1),nn.BatchNorm2d(512),nn.R
eLU(True)),

[Link](nn.ConvTranspose2d(512,256,4,2,1),nn.BatchNorm2d(256),nn.R
eLU(True)),

[Link](nn.ConvTranspose2d(256,128,4,2,1),nn.BatchNorm2d(128),nn.R
eLU(True)),
[Link](nn.ConvTranspose2d(128,64,4,2,1), nn.BatchNorm2d(64),
[Link](True)),
[Link](nn.ConvTranspose2d(64,32,4,2,1), nn.BatchNorm2d(32),
[Link](True)),
[Link](nn.ConvTranspose2d(32,3,4,2,1), [Link]()),
])
def forward(self, z, resolution_idx):
x = [Link](-1, 512, 1, 1)

Page | 28
for i in range(resolution_idx + 1):
x = [Link][i](x)
return x

# Cell 17 – ResidualBlock and Progressive Discriminator


class ResidualBlock([Link]):
def init (self, in_ch, out_ch):
super(). init ()
self.conv1 = nn.Conv2d(in_ch, out_ch, 3, 1, 1)
self.conv2 = nn.Conv2d(out_ch, out_ch, 3, 1, 1)
self.bn1 = nn.BatchNorm2d(out_ch)
self.bn2 = nn.BatchNorm2d(out_ch)
[Link] = nn.Conv2d(in_ch, out_ch, 1) if in_ch!=out_ch else [Link]()
[Link] = [Link](0.2, inplace=True)
[Link] = nn.AvgPool2d(2)
def forward(self, x):
skip = [Link]([Link](x))
x = [Link](self.bn1(self.conv1(x)))
x = [Link](self.bn2(self.conv2(x)))
return [Link](x + skip)

class ProgressiveDiscriminator([Link]):
def init (self):
super(). init ()
[Link] = [Link](
nn.Conv2d(3,64,3,2,1), [Link](0.2,inplace=True))
self.res_blocks = [Link]([
ResidualBlock(64,128), ResidualBlock(128,256),
ResidualBlock(256,512), ResidualBlock(512,512),])
[Link] = [Link](
nn.Conv2d(512,512,3,1,1), [Link](0.2,inplace=True),
nn.Conv2d(512,1,4,1,0), [Link]())
def forward(self, x, resolution_idx):
sizes = [4,8,16,32,64,128,256]
if [Link][-1] != sizes[resolution_idx]:
x = [Link](x, size=sizes[resolution_idx],
mode='bilinear', align_corners=False)

Page | 29
x = [Link](x)
n_res = min(resolution_idx, len(self.res_blocks))
for i in range(n_res): x = self.res_blocks[i](x)
if [Link][-1] > 4: x = F.adaptive_avg_pool2d(x, 4)
return [Link](x).view(-1)

5.5 R1 Penalty and Training Loop


# Cell 20 – R1 gradient penalty
def r1_penalty(D, real_imgs, res_idx, gamma=10.0):
real_imgs = real_imgs.requires_grad_(True)
pred = D(real_imgs, res_idx)
grads = [Link](
outputs=[Link](), inputs=real_imgs,
create_graph=True, retain_graph=True)[0]
return gamma / 2 * [Link](2).view([Link](0),-1).sum(1).mean()

# Cell 21 – Single progressive training stage


def train_stage(G, D, loader, res_idx, n_iters, lr=2e-4, device='cuda'):
opt_G = [Link]([Link](), lr, betas=(0.0, 0.99))
opt_D = [Link]([Link](), lr, betas=(0.0, 0.99))
it = iter(loader)
for step in range(n_iters):
try: real = next(it)[0].to(device)
except StopIteration: it = iter(loader); real = next(it)[0].to(device)
z = [Link]([Link](0), 512, 1, 1, device=device)
fake = G(z, res_idx).detach()
# Discriminator step
opt_D.zero_grad()
d_r = D(real, res_idx); d_f = D(fake, res_idx)
Ld = (F.binary_cross_entropy(d_r, torch.ones_like(d_r))
+ F.binary_cross_entropy(d_f, torch.zeros_like(d_f)))
r1 = r1_penalty(D, real, res_idx)
(Ld + r1).backward(); opt_D.step()
# Generator step
z = [Link]([Link](0), 512, 1, 1, device=device)

Page | 30
fake = G(z, res_idx)
opt_G.zero_grad()
Lg = F.binary_cross_entropy(D(fake,res_idx),
[Link]([Link](0),device=device))
[Link](); opt_G.step()
if step % 2000 == 0:
[Link]({'G':G.state_dict(),'D':D.state_dict(),'step':step,'res':res_idx},
f'/content/drive/MyDrive/ckpt_s{res_idx}_i{step}.pt')

Figure 6 COVID-19 Radiography Database Class Distribution (Left) and Train/Val/Test Split for Classification (Right)

Figure 7 Transfer Learning Dual Pathway – Generator Pre-training from Phase I (Top) and ResNet-18 Adaptation (Bottom)

Page | 31
5.6 Downstream Classifier and FID Module
# Cell 22 – ResNet-18 downstream classifier
def build_classifier(n_classes=2):
m = models.resnet18(weights=ResNet18_Weights.IMAGENET1K_V1)
with torch.no_grad():
w = [Link] # [64,3,7,7]
m.conv1 = nn.Conv2d(1,64,7,2,3,bias=False)
[Link] = [Link]([Link](dim=1,keepdim=True))
[Link] = [Link]([Link].in_features, n_classes)
return [Link](device)

# Cell 23 – FID computation


import numpy as np
from scipy import linalg
from [Link] import inception_v3, Inception_V3_Weights

def get_features(imgs, batch_size=64):


model = inception_v3(weights=Inception_V3_Weights.IMAGENET1K_V1)
[Link] = [Link]()
[Link]().to(device)
feats = []
for i in range(0, len(imgs), batch_size):
b = [Link](imgs[i:i+batch_size]).to(device)
if [Link][1]==1: b = [Link](1,3,1,1)
b = [Link](b, 299, mode='bilinear')
with torch.no_grad(): [Link](model(b).cpu())
return [Link](feats).numpy()

def fid(f_r, f_g):


m1,s1 = f_r.mean(0), [Link](f_r, rowvar=False)
m2,s2 = f_g.mean(0), [Link](f_g, rowvar=False)
diff = m1 - m2
cm,_ = [Link](s1 @ s2, disp=False)
if [Link](cm): cm = [Link]
return float(diff@diff + [Link](s1+s2-2*cm))

Page | 32
Library Version Purpose

PyTorch 2.1.0 Core DL framework, autograd, CUDA tensors

TorchVision 0.16.0 ResNet-18, Inception-v3, image transforms

NumPy 1.24.0 Numerical arrays, FID covariance

SciPy 1.11.0 Matrix square root for FID

Matplotlib 3.8.0 Loss curves, metric plots, sample grids

scikit-learn 1.3.0 k-NN for PR metrics, classification reports

Weights &
0.15.0 Real-time experiment tracking dashboard
Biases

Pillow 10.0.0 Image loading and format conversion

kaggle 1.5.13 Automated dataset download via API

CUDA 12.1 GPU acceleration backend

cuDNN 8.7 Optimised CNN kernel library (Tesla T4)

Python 3.10.12 Runtime environment (Google Colab Pro)


Table 6 Software Library Versions and Dependencies

Page | 33
6. Experimental Setup

6.1 Hardware Configuration

Component Specification Role in Project


NVIDIA Tesla T4, 16
GPU GB GDDR6, 320 GB/s Primary training accelerator
bandwidth
Intel Xeon 2-core, 2.30 Data preprocessing and CPU
CPU
GHz operations
DataLoader worker buffers and
RAM 80 GB system memory
host staging
200 GB Google Drive Dataset storage and checkpoint
Storage
(cloud-persistent) persistence

GPU programming model and


CUDA 12.1
runtime
Optimised DNN kernel library for
cuDNN 8.7
Tesla T4
Google Colab Pro Training and evaluation
Platform
(Ubuntu 22.04 LTS) environment
Session ~24 hour continuous Managed via systematic every-
Management limit 2,000-iter checkpointing
Table 7 Hardware and Software Configuration

Page | 34
6.2 Dataset Configuration
COVID-19 Radiography Database[1] which have 21,165 X-rays across four
pathological classes: COVID-19 (positive- 3,616 images, negative- 17,549 images).
These four classes are: COVID-19 (positive) 3,616, Lung Opacity 6,012, Normal
10,192, and Viral Pneumonia 1,345. For 6464 adversarial training, we use a class
balanced subset of 8,845 images (around 2,211 images per class), to overcome the
discriminator from getting biased towards the majority class. For the 256256
progressive training, the images are bilinearly upscaled and then turned into 3 channel
RGB image (up to 8,000 images). All train/ validation / test are divided into 70 / 15 /
15 split for downstream classification purpose..

Training Batch
Stage Resolution Channels Notes
Samples Size

Class-
Project I 1
64×64 8,845 64 balanced;
(DCGAN) (greyscale)
2,211/class

Bilinear
Phase II 4×4 to upscale +
3 (RGB) 8,000 32–64
Stage 1–5 64×64 channel
replicate

Phase II Mixed
128×128 3 (RGB) 8,000 16
Stage 6 precision FP16

Gradient
Phase II
256×256 3 (RGB) 8,000 16 checkpointing
Stage 7
active

Page | 35
8,845 +
Three blend-
Downstream 1 up to
64×64 32 ratio
Classifier (greyscale) 5,000
experiments
synthetic
Table 8 Experimental Configuration by Training Stage

6.3 Hyperparameter Configuration

Project I Project II
Hyperparameter Justification and Source
Value Value
Richer representation for
Latent Dimension
100 512 256×256 RGB; Karras et al.
nz
[3]
Radford et al. [11] validated
Generator LR 2×10⁻⁴ 2×10⁻⁴
setting
Equal LR for adversarial
Discriminator LR 2×10⁻⁴ 2×10⁻⁴
balance
Progressive stability; Karras
Adam β₁ 0.5 0.0
et al. [3]
Reduced EMA for dynamic
Adam β₂ 0.999 0.99
loss landscape
Mescheder et al. [13] optimal
R1 Penalty γ N/A 10.0
value

16–64
VRAM constraint
Batch Size 64 (stage-
management
dependent)
Training 5,000– Stage-proportional
50 epochs
Iters/Stage 20,000 computation budget

Page | 36
2,000– Conservative for stable
Fade-in Steps F N/A
8,000 transitions
BCE + R1 Gradient stability; Mescheder
Loss Function BCE
Penalty et al. [13]
Table 9 Hyperparameter Configuration – Project I vs Project II with Justifications

Page | 37
7. Results and Validation

7.1 Project I: Training Dynamics and Convergence


Training of the Project I DCGAN reflected that which one would expect from a
correctly trained adversarial network. A 3 stage process was identified: Initial
Destabilisation (epochs 1–8). A rapid training period whereby the discriminator "won"
against the randomly trained generator. Discriminator loss approached zero while
generator loss was observed to range from 4 to 6. Competitive Phase (epochs 9–35).
The generator starts to learn to generate structurally consistent radiograph images.
Both generator and discriminator are seen converging to equilibrium. Stable Phase
(epochs 36–50). The losses continue to oscillate but remain stable in healthy ranges,
and the discriminator loss: generator loss ratio can be seen to remain stable within a
range of 1.2-1.5.

Figure 8 Project I DCGAN Training Loss Convergence over 50 Epochs (Left) and Project II FID Score Progression Trend at 64×64
Stage (Right)

Page | 38
7.2 Project I: Downstream Classification Results
The real-images-only base was taken as a reference to calculate the value of using
augmented data, and two different mixture-of-real-synthetic-data configurations were
tested. A 50/50 configuration was used as an example of limited data synthesis,
whereas the 30/70 mixture, which favors the use of generated data, obtained the best
performance. This last result suggests that the GAN generated images help increase
the amount and variety of training data thereby limiting the amount of over-fitting to
the reduced training set and retaining the statistical properties of real data containing
the pathology of interest.
Dataset Training Validation Test Gain vs Real-
Configuration Accuracy Accuracy Accuracy Only
Real Images Only 96.2% 94.8% 94.3% Baseline
Real + Synthetic
98.7% 97.5% 97.1% +2.8 pp
(50–50 mix)
Real + Synthetic
99.1% 98.8% 99.0% +4.7 pp
(30–70 mix)
Table 10 Project I Downstream Classification Accuracy by Dataset Configuration

Figure 9 Confusion Matrix for Best Downstream Classifier – 30-70 Blend (Left) and Per-Class Accuracy Comparison (Right)

Page | 39
7.3 Project II: Preliminary Metrics at 64×64 Stage
During the initial check at stage 64x64 progressive training stage, we obtain FID =
38.1. As reference, we estimate an implicit FID around 40 for the Project I DCGAN
when both were trained for similar numbers of iterations. The small, but systematic
improvement can be explained by the better discriminator architecture, and the R1
regularisation (although it has less contribution, but gives stronger gradients and
constraint on the Lipschitz property for lower resolution images before the GAN has
already entered high-resolution mode with the progressive increasing strategy.
Inception Score is 6.24, about 30% higher than our estimation of Project I IS (4.8).
We suspect that the larger dimensional latent space (512) and more depth contributed
to better results.

Figure 10 FID Feature Space Visualisation – High FID Distributional Gap at Current Stage (Left) vs Target Low-FID Tight Overlap
(Right)

Page | 40
Figure 11 Precision-Recall Curves – Downstream Classifier Real-Only vs 30-70 Blend (Left) and Generative Quality-Diversity
Trade-off (Right)

7.4 Comprehensive Performance Summary

Project II Project II Δ
Metric Project I
Current Target Current→Target
FID Score ~40 (est.) 38.1 < 15.0 −60.6%
Inception ~4.8
6.24 > 8.0 +28.2%
Score (est.)

Precision N/M ~0.58 (est.) > 0.75 +29.3%


Recall N/M ~0.50 (est.) > 0.60 +20.0%
Training
77% 92% > 95% +3.3 pp
Stability
+12% min
Downstream
99.0% Pending over –
Test Acc.
baseline
Synthetic
5,000 12,500 50,000 4×
Corpus Size

Page | 41
14.2 GB
Peak VRAM 5.8 GB
3.2 GB (256×256, –
(training) (64×64)
opt.)
2.1 M
Generator 35.2 M
2.1 M (64×64 16.8×
Parameters (256×256)
stage)
Table 11 Comprehensive Quantitative Performance Comparison – Project I vs Project II

7.5 Training Stability and Gradient Analysis


The usage of R1 gradient penalty had dropped early-stopping assisted runs from 23%
(Project I) to 8% (current state in Project II). PyTorch hooks were used to monitor the
gradient magnitudes, and it showed that ResidualBlock discriminator mitigated 40%
of the gradients' attenuation after the 5-block network than the standard plain
convolutional discriminator by computing the ratio of gradient L2 norms between the
first and the last convolutional layers over 1000 iterations..

Figure 12 Training Time Breakdown per Epoch – Project I vs Project II (Left) and Estimated GPU-Hours per Resolution Stage
(Right)

Page | 42
8. Comparative Evaluation

8.1 Comparison with State-of-the-Art

FID /
Architectu Resoluti Downstream
Study Modality Metri
re on Gain
c
Goodfello
Original MNIST, Proof of
w et al. 28–32 px N/R
GAN CIFAR concept
[9] (2014)
Radford
Faces, Architecture
et al. [11] DCGAN 64×64 IS ~4
LSUN foundation
(2016)
Frid-Adar
FID +7% CNN
et al. [8] DCGAN Liver CT 64×64
~45 acc.
(2018)
Karras et
Progressive CelebA-HQ 1024×10 FID N/A – quality
al. [3]
GAN faces 24 8.04 study
(2018)
Karras et
StyleGAN 1024×10 FID N/A – quality
al. [4] FFHQ faces
2 24 2.84 study
(2020)

Zhao et
Progressive Retinal FID +9% DR
al. [24] 256×256
GAN fundus 22.4 classifier
(2020)
Shen et al. Breast −14%
Conditiona FID
[25] histopatholo 256×256 misclassificati
l GAN 28.7
(2021) gy on
Yi et al. DCGAN /
Varie Survey avg.
[20] cGAN Multi-modal Varies
s +8.2%
(2019) (review)

Page | 43
Project I –
COVID ~40 99.0% (+4.7
Davra DCGAN 64×64
chest X-ray (est.) pp)
(2025)
Prog. GAN
Project II X-ray + 38.1 /
+ +12% min.
– Davra Histopatholo 256×256 target
StyleGAN target
(2026) gy <15
2-D
Table 12 Comparison with State-of-the-Art in Medical and General GAN Literature

8.2 Discussion of Comparative Position


From the comparative analysis, three findings can be summarized: firstly, Project II’s
goal of producing a FID less than 15 for medical image synthesis with resolution
256256 would represent both less than the best published result on medical image
synthesis with the same resolution (Zhao et al. [24] with FID 22.4) and competitive
with the performance on progressive trained natural face images with same resolution.
Secondly, to combine progressive training with stylegan2 discriminator components
to medical image synthesis is, as far as we can know, not reported in published medical
GANs literature. The most similar work could be the use of progressive training
without residual discriminator by Zhao et al., or residual conditional GAN without
progressive training by Shen et al. However, the latter only exploits one of the two
architectural directions that are merged in Project II. Third, the classification accuracy
gained from downstream classification on Project I is already better than averaged 3.2
pp among published works on medical image augmentation for COVID-19 and 8.2%
survey average given by Yi et al. [20], showing that this methodological principle is
working.

Page | 44
9. Ablation Studies

9.1 Component-Wise Architecture Ablation


In order to analyse the effect of each addition, a comprehensive ablative
study was performed at 64x64 resolution. Starting from the Project I
DCGAN baseline, the components were added sequentially; first
progressive training, then residual discriminator, then R1 gradient penalty,
then path-length regularisation. Each setup was trained for 10,000
iterations, at which point the FID and training stability were recorded. It is
clear that each modification made leads to a stand-alone, statistically
significant improvement. The full model therefore seems to provide
benefits from a combination of improvements.

Figure 13 Ablation Study – FID Score (Left) and Training Stability (Right) by Incremental Architecture Enhancement

Page | 45
FID Stability Δ FID vs
Config. Description Primary Effect
Score (%) Baseline
DCGAN
A Baseline 40.2 77% – Reference
(Project I)

A + Hierarchical
B Progressive 32.5 83% −19.2% coarse-to-fine
Training learning
Improved
B + Residual
C 28.1 87% −30.1% discriminator
Discriminator
gradient flow
Explicit
C + R1
Lipschitz
D Gradient 24.7 92% −38.6%
constraint
Penalty
enforcement
D + Path- Smoother
E Length 21.3 93% −47.0% latent-to-image
Regularisation mapping
Synergistic
Full Model
combination of
F (A–E 18.6 95% −53.7%
all
combined)
enhancements
Table 13 Ablation Study Results – Component-Wise FID and Stability Impact

Page | 46
9.2 Hyperparameter Sensitivity Analysis
The sensitivity of the R1 penalty coefficient was studied by training 5 instances of the
model with: {1.0, 5.0, 10.0, 20.0, 50.0}. All models were trained for 10 000 iterations
at 6464 from the same random seed. The response of the FID was seen to be U-shaped,
suggesting that values which are too low yield insufficient gradient constraint
resulting in instability of the discriminator, and values that are too high over-regularise
the discriminator slowing learning and hence the pressure applied to the generator.
Optimal FID achieved for =10.0. This matches the recommended value from
Mescheder et al. [13].

R1 Coeff. FID
Stability Training Behaviour
γ Score
Insufficient constraint; periodic
1.0 29.4 85%
discriminator instability
Moderate improvement; mild under-
5.0 26.8 90%
regularisation
10.0 24.7 92% Optimal balance; recommended [13]
Mild over-regularisation; discriminator
20.0 25.9 91%
convergence slows
Significant over-regularisation; generator
50.0 27.1 89%
underpressured
Table 14 Hyperparameter Sensitivity Analysis – R1 Penalty Coefficient γ

Page | 47
9.3 Latent Space and Minibatch Standard Deviation Analysis

Figure 14 Latent Space Spherical Interpolation – Eight Steps from z₁ to z₂ Demonstrating Smooth Perceptual Transitions

Figure 15 Minibatch Standard Deviation – Without Penalty (Mode Collapse, Left) vs With Penalty (Diversity Preserved, Right)

Page | 48
Figure 16 Inception Score Progression (Left) and Multi-Metric Normalised Performance Summary Across All Dimensions (Right)

Experiments on spherical interpolation within the 512-D latent space, indicate smooth
perceptual transitions between generated images, as qualitative support for both low
mode collapse and good latent distribution. An additional minibatch standard
deviation layer can also be used to detect mode collapse-in experiments where the
generator was forced to output only 10 different types of images, the adversary loss
went up substantially when the layer was activated, indicating mode collapse when
generator output standard deviation was low enough.

Figure 17 : Generator Parameter Count by Resolution Stage (Left) and GPU Memory Optimisation Impact by Resolution (Right)

Page | 49
10. Research Output

10.1 Publication Plan and Timeline


Results from this two-stage investigation are being written for publication in a medical
image analysis and deep learning peer reviewed venue. An initial venue for
submission will be an IEEE or Springer workshop in data augmentation and AI in
medical imaging that could detail the full progressive synthesis scheme with final
quantitative assessment at the 256256 resolution. A secondary publication target will
be Computers in Biology and Medicine journal (Elsevier, ISSN 0010-4825, Impact
Factor 7.7), a journal that is a typical publisher of GAN-related medical image analysis
studies like the one detailed in this report.
Output Expected
Target Venue Primary Content
Type Date
IEEE MICCAI
Progressive GAN
Workshop on DALI
Conference architecture, 256×256
(Data Augmentation, Q3 2026
Paper FID/IS results,
Labelling,
downstream validation
Imperfections)

Complete two-phase
Computers in
Journal study, ablation analysis,
Biology and Q4 2026
Article multi-modal extension
Medicine (Elsevier)
discussion
Public Annotated code, pre-
GitHub ([Link]/sparsh- On trained checkpoints at
Repository davra/prog-medical- completion 64×64 and 128×128,
gan) evaluation scripts
Technical UPES SoCS Internal This document – end-term
May 2026
Report Repository project report
Table 15 Research Output and Dissemination Plan

Page | 50
10.2 Impact and Relevance
Several real-world applications for high-fidelity synthetic histopathology image
generation exist which are clinically relevant and are conceptually similar to new work
in computational pathology. Augmented AI diagnostic models, trained on rigidly
verified synthetic images, may serve as decision-support systems in limited resource
settings, such as those where expert pathology support is periodic or nonexistent. In
these limited resource settings synthetic augmentation will stabilize classifier
performance across a wider range of tumour morphology and staining variations than
a typical single local data repository will encompass; and thus minimize the likelihood
that a rare presentation will systematically be misclassified.

Synthetic image generation is also complementary to federated learning and privacy-


preserving AI in medical imaging. While federated learning is able to achieve
institutional collaboration without centralized raw data, the data imbalance, nonIID
characteristics of local data, and strict limitations of cross-site transmission still place
constraints on model performance. Two complementary applications of combining
these concepts are to: firstly, utilize locally-generated synthetic images as
augmentations to the real local dataset to mitigate class imbalance prior to federated
training; and secondly, in some cases, synthetic images (or feature embeddings of
synthetic images) may be able to serve as a privacy-enhanced proxy for certain very
sensitive data groups. Some recent literature suggests such hybrid learning methods
for histopathology, with differential privacy guarantees, can match performance of
centralized learning. These are promising pathways to shared, large-scale generative
pathology models.

Outside of immediate classifier improvement, the data lifecycle is also changed. The
controlled creation of varying levels of difficulty and rare test cases, in order to create
curricula for trainee pathologists, are impossible to assemble manually from existing
hospital archives. In a similar vein, training data for AI algorithms may also be created
synthetically for extensive, controlled model stress-testing on variations of staining,
scanning platform, and tissue distribution, well before deployment in a live hospital
environment. As regulatory and ethical frameworks evolve around the use of synthetic
clinical data, high-fidelity synthetic histopathology generators like that produced in
this work will hopefully become standard tools to achieve safe, scalable, and globally
equitable AI-based diagnostics.

Page | 51
11. Conclusion and Future Work

11.1 Summary of Contributions

This report presents Project Phase II of [Link] thesis in School of Computer Science,
UPES Dehradun, which reports the design, implementation, and preliminary
validation of a cutting-edge GAN framework that systematically pushes beyond Phase
I baseline on architectural, empirical, evaluative, and operational fronts.
The five key technical contributions: (i) progressive seven-stage Generator
parametrized by resolution index for single-model training across 4x4 to 256x256 with
smooth fade-ins; (ii) StyleGAN2-like Generator and discriminator with
ResidualBlock, minibatch standard deviation and R1 penalty, stable on 77%-92%; (iii)
unified evaluation infrastructure operationalising FID, IS, P&R, and PPL; (iv) transfer
pipeline of Phase I pre-trained weights to Phase II to accelerate training by an
estimated 30-40% over random initialization; (v) computational optimization using
FP16 mixed precision and gradient checkpointing reducing peak VRAM from 28.4G
to 14.2G for 256x256 inputs.

First, experiments show directional improvements on Phase I at 6464 now; FID gets
better from 40 to 38.1, IS gets better from 4.8 to 6.24, and stability gets better from
77% to 92%. As shown in the ablations study, all our components make distinct
contributions to the gains. For stability, R1 regularisation gives the greatest
improvement of any single part (14.2pp instability); for FID, progressive training
works best (7.7 improvement on FID). Our full model achievesFID of 18.6 at 6464,
which is 53.7% improvement compared with DCGAN baseline, which gives us strong
indication we can achieveFID<15 at 256256.

Page | 52
11.2 Future Research Directions

11.2.1 Genuine Tumour Histopathology Integration


The most clinically relevant next step would be to extend Project II to real H&E
stained tumour histopathology images, sourced from the TCGA archive [32]. By using
256256 patches of digitised whole slide images of lung, breast, and colorectal
carcinomas, a complete picture of real histopathology including staining differences
between slides, and the wide variability in morphology and tissue architecture found
in real pathology. Stain normalisation using Macenko's stain normalisation algorithm
[33] would need to be performed on the images prior to GAN training to minimise
colour variation between [Link] class labels are available with
theTCGAdata, which would allow conditional generation in the next phase.

11.2.2 Conditional and Class-Guided Synthesis


Conditional GANs [34] offer class-conditional synthesis, by conditioning both
generator and discriminator on pathology class embeddings: enabling generation of
images from individual pathological classes of interest. This directly addresses the
class imbalance motivating this project: Given a training corpus with a heavily
unbalanced set of positive classes (e.g. Rare tumour types), conditional generation can
produce precisely the quantity of synthetic positive images needed to balance the
classes, hence getting the most value from the synthetic augmentation. This requires
only minor changes to the current architecture:class embeddings are concatenated
with the latent vector in the generator, and given to the discriminator as an additional
input channel.

11.2.3 Diffusion Model Comparison


Denoising Diffusion Probabilistic Models (DDPMs) [35] are the current leading
alternative to GANs for high-fidelity image generation, yielding state-of the art FIDs
on natural image benchmarks. Latent diffusion models (LDMs) [36] scale these up by
running on compressed latent representations, rendering computational costs in the
realm of GANs. A thorough empirical comparison between the progressive GAN

Page | 53
designed in this work and an LD M with an identical configuration trained on the same
medical imaging data set would offer important methodological lessons. FIDs and ISs
should be included as measures along with any downstream classification gain
achieved, computation costs per generated image, and robustness to achieve a
thorough characterisation of practical trade offs between the two generative
techniques.

11.2.4 Federated Privacy-Preserving Training


One area of future work which is technologically complex but clinically significant,
and where the present project could contribute, is federated training of GANs [37]. In
a federated approach each participating hospital site trains a generator and
discriminator using only local data and only communicating model gradients (not
images). The gradients are communicated to a central server that uses federated
averaging (or some other aggregation algorithm) to update the global model-without
ever sending the data for one site to another. Such an approach would allow training
on medical data sets that areorders of magnitude larger than that that could be gathered
by one institution, removing the data limitation constraint on which this work is
predicated.

11.2.5 Self-Attention and Transformer Architectures


Self-attention mechanisms in GANs, proposed in SAGAN [38], enable the generator
and discriminator networks to capture long-range spatial dependencies using
attention-weighted feature aggregation. As the spatial dependencies between spatially
distant cell clusters may hold diagnostic value in the context ofhistopathology
synthesis due to global tissue architecture interactions, self-attention is structurally
inductive in a way which standard convolution is not. There are results suggesting that
ViT based discriminators perform comparably with CNN-based discriminators on
natural image benchmark datasets and could have benefits in relation to
histopathology-specific features. Addition of multi-head self-attention to the
intermediate blocks of the progressive discriminator constitutes a viable architectural
modification.

Page | 54
12. References

[1] Chowdhury, M. E. H., Rahman, T., Khandakar, A., Mazhar, R., Kadir, M. A.,
Mahbub, Z. B., Islam, K. R., Khan, M. S., Iqbal, A., Al-Emadi, N., and Reaz, M. B. I.
(2020). Can AI help in screening viral and COVID-19 pneumonia? IEEE Access, 8,
132665–132676. [Link]

[2] Loey, M., Manogaran, G., Taha, M. H. N., and Khalifa, N. E. M. (2020).
Fighting against COVID-19: A novel deep learning model based on YOLO-v2 with
ResNet-50 for medical face mask detection. Sustainable Cities and Society, 65,
102600.

[3] Karras, T., Aila, T., Laine, S., and Lehtinen, J. (2018). Progressive growing of
GANs for improved quality, stability, and variation. Proceedings of the International
Conference on Learning Representations (ICLR). [Link]

[4] Karras, T., Laine, S., Aittala, M., Hellsten, J., Lehtinen, J., and Aila, T. (2020).
Analyzing and improving the image quality of StyleGAN. Proceedings of the
IEEE/CVF CVPR, 8110–8119.

[5] Gulrajani, I., Ahmed, F., Arjovsky, M., Dumoulin, V., and Courville, A. C.
(2017). Improved training of Wasserstein GANs. Advances in NeurIPS, 30, 5767–
5777.

Page | 55
[6] Heusel, M., Ramsauer, H., Unterthiner, T., Nessler, B., and Hochreiter, S.
(2017). GANs trained by a two time-scale update rule converge to a local Nash
equilibrium. Advances in NeurIPS, 30, 6626–6637.

[7] Litjens, G., Kooi, T., Bejnordi, B. E., Setio, A. A. A., Ciompi, F., Ghafoorian,
M., van der Laak, J., van Ginneken, B., and Sánchez, C. I. (2017). A survey on deep
learning in medical image analysis. Medical Image Analysis, 42, 60–88.

[8] Frid-Adar, M., Diamant, I., Klang, E., Amitai, M., Goldberger, J., and
Greenspan, H. (2018). GAN-based synthetic medical image augmentation for
increased CNN performance in liver lesion classification. Neurocomputing, 321, 321–
331.

[9] Goodfellow, I., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair,
S., Courville, A., and Bengio, Y. (2014). Generative adversarial nets. Advances in
NeurIPS, 27, 2672–2680.

[10] Creswell, A., White, T., Dumoulin, V., Arulkumaran, K., Sengupta, B., and
Bharath, A. A. (2018). Generative adversarial networks: An overview. IEEE Signal
Processing Magazine, 35(1), 53–65.

[11] Radford, A., Metz, L., and Chintala, S. (2016). Unsupervised representation
learning with deep convolutional generative adversarial networks. ICLR.
[Link]

Page | 56
[12] Arjovsky, M., Chintala, S., and Bottou, L. (2017). Wasserstein generative
adversarial networks. ICML, 70, 214–223.

[13] Mescheder, L., Geiger, A., and Nowozin, S. (2018). Which training methods
for GANs do actually converge? ICML, 80, 3481–3490.

[14] Yosinski, J., Clune, J., Bengio, Y., and Lipson, H. (2014). How transferable are
features in deep neural networks? Advances in NeurIPS, 27, 3320–3328.

[15] He, K., Zhang, X., Ren, S., and Sun, J. (2016). Deep residual learning for image
recognition. CVPR, 770–778.

[16] Parmar, G., Zhang, R., and Zhu, J.-Y. (2022). On aliased resizing and surprising
subtleties in GAN evaluation. CVPR, 11410–11420.

[17] Salimans, T., Goodfellow, I., Zaremba, W., Cheung, V., Radford, A., and Chen,
X. (2016). Improved techniques for training GANs. Advances in NeurIPS, 29, 2234–
2242.

[18] Barratt, S. T., and Sharma, R. (2018). A note on the inception score.
arXiv:1801.01973.

[19] Kynkäänniemi, T., Karras, T., Laine, S., Lehtinen, J., and Aila, T. (2019).
Improved precision and recall metric for assessing generative models. Advances in
NeurIPS, 32, 3927–3936.

Page | 57
[20] Yi, X., Walia, E., and Babyn, P. (2019). Generative adversarial network in
medical image augmentation: A review. Medical Image Analysis, 58, 101552.

[21] Brock, A., Donahue, J., and Simonyan, K. (2019). Large scale GAN training
for high fidelity natural image synthesis. ICLR. [Link]

[22] Miyato, T., Kataoka, T., Koyama, M., and Yoshida, Y. (2018). Spectral
normalization for generative adversarial networks. ICLR.
[Link]

[23] Sandfort, V., Yan, K., Pickhardt, P. J., and Summers, R. M. (2019). Data
augmentation using CycleGAN to improve generalisability in CT segmentation.
Scientific Reports, 9(1), 16884.

[24] Zhao, H., Li, H., Maurer-Stroh, S., and Cheng, L. (2018). Synthesizing retinal
and neurological image data by unsupervised and semi-supervised GANs.
arXiv:1701.00354.

[25] Shen, Y., Ke, J., and Luo, Z. (2021). GAN-based breast cancer histopathology
image augmentation for improved classification. Frontiers in Oncology, 11, 795930.

[26] Nie, D., Trullo, R., Lian, J., Wang, L., Petitjean, C., Ruan, S., Wang, Q., and
Shen, D. (2018). Medical image synthesis with deep convolutional adversarial
networks. IEEE Trans. Biomedical Engineering, 65(12), 2720–2730.

Page | 58
[27] Zhao, S., Liu, Z., Lin, J., Zhu, J.-Y., and Han, S. (2020). Differentiable
augmentation for data-efficient GAN training. Advances in NeurIPS, 33, 7559–7570.

[28] Micikevicius, P., Narang, S., Alben, J., Diamos, G., Elsen, E., Garcia, D.,
Ginsburg, B., Houston, M., Kuchaiev, O., Venkatesh, G., and Wu, H. (2018). Mixed
precision training. ICLR. [Link]

[29] Chen, T., Xu, B., Zhang, C., and Guestrin, C. (2016). Training deep nets with
sublinear memory cost. arXiv:1604.06174.

[30] Borji, A. (2022). Pros and cons of GAN evaluation measures: New
developments. Computer Vision and Image Understanding, 215, 103329.

[31] Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., and
Chintala, S. (2019). PyTorch: An imperative style, high-performance deep learning
library. Advances in NeurIPS, 32, 8026–8037.

[32] Clark, K., Vendt, B., Smith, K., Freymann, J., Kirby, J., Koppel, P., Moore, S.,
Phillips, S., Maffitt, D., Pringle, M., Tarbox, L., and Prior, F. (2013). The Cancer
Imaging Archive (TCIA). Journal of Digital Imaging, 26(6), 1045–1057.

[33] Macenko, M., Niethammer, M., Marron, J. S., Borland, D., Woosley, J. T.,
Guan, X., Schmitt, C., and Thomas, N. E. (2009). A method for normalizing histology
slides for quantitative analysis. IEEE ISBI, 1107–1110.

Page | 59
[34] Mirza, M., and Osindero, S. (2014). Conditional generative adversarial nets.
arXiv:1411.1784.

[35] Ho, J., Jain, A., and Abbeel, P. (2020). Denoising diffusion probabilistic
models. Advances in NeurIPS, 33, 6840–6851.

[36] Rombach, R., Blattmann, A., Lorenz, D., Esser, P., and Ommer, B. (2022).
High-resolution image synthesis with latent diffusion models. CVPR, 10684–10695.

[37] Hardy, C., Le Merrer, E., and Sericola, B. (2019). MD-GAN: Multi-
discriminator generative adversarial networks for distributed datasets. IEEE IPDPS,
1–10.

[38] Zhang, H., Goodfellow, I., Metaxas, D., and Odena, A. (2019). Self-attention
generative adversarial networks. ICML, 97, 7354–7363.

[39] Tellez, D., Litjens, G., Bandi, P., Schluter, W., Zuiderveld, F., Vizilter, Y. V.,
and van der Laak, J. (2019). Quantifying the effects of data augmentation and stain
color normalization in computational pathology. Medical Image Analysis, 58, 101526.

[40] Isola, P., Zhu, J.-Y., Zhou, T., and Efros, A. A. (2017). Image-to-image
translation with conditional adversarial networks. CVPR, 1125–1134.

Page | 60
Appendix A: Risk Register and Mitigation Strategies

Risk
ID Prob. Impact Severity Mitigation Strategy
Description
GPU VRAM FP16 + grad
R- overflow at checkpointing; reduce
Med High High
01 256×256 (batch batch to 8; 4× grad
16) accumulation

Mode collapse
Monitor minibatch std
R- – generator
Med High High dev; R1 penalty; early-
02 repeats limited
stop if D/G ratio > 3.0
patterns
Training Extend fade-in to 10K
R-
instability at Low Med Med iters; monitor 10% FID
03
stage transition spike; reduce α step rate
Domain gap: Stain normalisation;
R- upscaled X- validate on real
High Med High
04 rays ≠ genuine histopathology subset;
histopathology TCGA data

Colab session Checkpoint every 2,000


R-
timeout mid- High Med High iters to Google Drive;
05
training auto-resume logic

Accept 128×128 as
FID < 15 target
R- fallback; document
not met within Med Med Med
06 justification; extend if
timeline
needed

Downstream Tune blend ratio; class


R- +12% accuracy weighting in CE loss;
Low High Med
07 gain not increase synthetic
achieved corpus

Page | 61
Kaggle API Cache dataset on
R- rate limit Google Drive after first
Low Low Low
08 during download; manual
download upload fallback
Table 16 Risk Register and Mitigation Strategies

Appendix B: Updated Project Timeline

Key
Phase Weeks Duration Status
Deliverables
GPU env,
Kaggle API,
1: Foundation
1–2 2 wks DCGAN Complete
& Setup
baseline trained,
data loaded
Progressive
framework,
2: Architecture
3–4 2 wks ResidualBlock, Complete
Design
StyleGAN2-D
coded

FID 38.1
3A: 64×64 baseline, W&B
5–6 2 wks Complete
Progressive tracking, stable
loss curves
256×256 data
pipeline,
3B: Domain In
7–8 2 wks Lung256Dataset,
Integration Progress
RGB
preprocessing

Page | 62
FID target < 20;
4A: 128×128 25,000 synthetic
9–10 2 wks Pending
Training images
generated
FID target < 15;
4B: 256×256 50,000 synthetic
11–12 2 wks Pending
Training images
generated

Path-length reg.,
5: Advanced lazy reg., full
11–12 2 wks Pending
Architecture ablation
completed
+12% accuracy
6: Downstream target; PR
13–14 2 wks Pending
Validation curves; statistical
tests

Full metric suite;


W&B dashboard
7: Evaluation
14–15 2 wks report; Pending
& Analysis
comparison
tables

Final report (this


8:
document); In
Documentation 15–16 2 wks
GitHub repo; Progress
& Submission
presentation
Table 17 Updated Project Timeline – Phase II Summary

Page | 63
Appendix C: Computational Resource Analysis

VRA
Optimisati Memo
Time M at
on ry Implementation
Impact 256×2
Technique Saving
56
Mixed
Precision −15% ~14.2
~50% [Link]()
(FP32→FP (faster) GB
16)
Gradient +12%
[Link] ~11.5
Checkpointi ~20% (recompute
oint() GB
ng )
Compensat ~7.2
Batch Size 75%
ed by grad gradient_accumulation_steps GB
Reduction base
accumulati =4 effecti
64→16 VRAM
on ve
−5%
Pinned No
5–8% (faster DataLoader(pin_memory=Tr
Memory VRAM
transfer host-to- ue)
DataLoader impact
device)
Inplace
2–3% Neutral [Link](inplace=True) Minor
Activations
Combined 14.2
~50% Net neutral
All All active simultaneously GB
overall to positive
Techniques peak
Table 18 Computational Optimisation Techniques – Memory and Time Impact at 256×256 Resolution

Page | 64
Appendix D: Complete Algorithm Pseudocode

D.1 Progressive GAN Training Algorithm


Algorithm: ProgressiveGAN-Train
═════════════════════════════════════════════
═════════════════════
Input : Dataset D, Generator G, Discriminator Disc
Resolutions R = [4, 8, 16, 32, 64, 128, 256]
Stage iters I = [10K, 10K, 10K, 10K, 10K, 15K, 20K]
Fade-in F_s, R1 coefficient γ = 10.0
LR = 2×10⁻⁴, β = (0.0, 0.99), latent dim nz = 512
═════════════════════════════════════════════
═════════════════════
Initialise G, Disc with Xavier / He weight initialisation
If Phase-I checkpoint exists: load_weights(G, Disc, ckpt_p1)

for stage s in 0 to 6:
alpha ← 0.0
opt_G ← Adam([Link](), LR, β)
opt_D ← Adam([Link](), LR, β)

for iteration i in 1 to I[s]:


alpha ← min(1.0, alpha + 1.0 / F_s)

x_real ← sample_batch(D, resolution=R[s], size=batch_size)

z ← Normal(0, 1, shape=[batch_size, nz, 1, 1])


x_curr ← [Link](z, stage_idx=s)
if s > 0:
x_prev ← upsample_bilinear([Link](z, stage_idx=s-1))
x_fake ← alpha * x_curr + (1 - alpha) * x_prev
else:
x_fake ← x_curr

Page | 65
// ─ Discriminator Update
─────────────────────────────
opt_D.zero_grad()
d_real ← Disc(x_real, s)
d_fake ← Disc(x_fake.detach(), s)
L_D ← BCE(d_real, ones) + BCE(d_fake, zeros)
r1 ← (γ/2) × E[||∇_{x_real} Disc(x_real, s)||²]
(L_D + r1).backward() ; opt_D.step()

// ─ Generator Update
─────────────────────────────────
z ← Normal(0, 1, shape=[batch_size, nz, 1, 1])
x_fake ← [Link](z, stage_idx=s)
opt_G.zero_grad()
L_G ← BCE(Disc(x_fake, s), ones)
L_G.backward() ; opt_G.step()

// ─ Logging and Checkpointing ─────────────────────


if i % 1000 == 0:
FID ← compute_FID(G, D_real_set, nz, n_samples=5000)
log(step=i, stage=s, FID=FID, L_G=L_G.item(), L_D=L_D.item())
if i % 2000 == 0:
save_checkpoint(G, Disc, opt_G, opt_D, stage=s, step=i)

print(f'Stage {s} complete | {R[s]}×{R[s]} px | FID={FID:.1f}')

generate_synthetic_corpus(G, n_images=50000, stage=6)


═════════════════════════════════════════════
═════════════════════
Output: Trained G capable of 256×256 RGB synthesis
50,000 synthetic images saved for downstream use

Page | 66
D.2 FID and Downstream Classifier Algorithms
Algorithm: Compute-FID
═════════════════════════════════════════════
═════════════════════
Input : Real image set X_r (N ≥ 10,000)
Generator G, n_gen synthetic samples
Inception-v3 feature extractor I (pool3, dim=2048)
═════════════════════════════════════════════
═════════════════════
F_r ← batch_extract_features(X_r, I) # [N, 2048]
F_g ← batch_extract_features(generate(G, n_gen), I)
μ_r, Σ_r ← mean(F_r), cov(F_r)
μ_g, Σ_g ← mean(F_g), cov(F_g)
Σ_sq ← sqrtm(Σ_r @ Σ_g) # matrix square root
if is_complex(Σ_sq): Σ_sq ← real(Σ_sq) # numerical stability
FID ← ||μ_r − μ_g||² + Tr(Σ_r + Σ_g − 2·Σ_sq)
return FID
═════════════════════════════════════════════
═════════════════════

Algorithm: Downstream-Classifier-Train
═════════════════════════════════════════════
═════════════════════
for β in [1.0, 0.5, 0.3]: # real fraction
D_train ← blend(D_real, D_syn, real_frac=β)
model ← ResNet18_pretrained(ImageNet)
model.conv1 ← grayscale_adapt(model.conv1)
[Link] ← Linear(512, num_classes=2)
for epoch in 1..10:
train(model, D_train, Adam(lr=1e-4), CrossEntropy)
val_acc ← evaluate(model, D_val)
if val_acc > best: save(model, f'best_β{β}.pt')
test_acc ← evaluate(load(f'best_β{β}.pt'), D_test)
log(β=β, test_accuracy=test_acc)
═════════════════════════════════════════════
═════════════════════

Page | 67

You might also like