File size: 8,576 Bytes
71c5436
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>4× Super-Resolution cGAN for Agricultural Leaf Images</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap" rel="stylesheet">
<style>
body { font-family: 'Inter', sans-serif; }
.gradient { background: linear-gradient(135deg, #052e16 0%, #15803d 50%, #22c55e 100%); }
.glass { backdrop-filter: blur(10px); background: rgba(255,255,255,0.78); }
.code-card { background: #0f172a; color: #e2e8f0; }
pre { white-space: pre-wrap; }
</style>
</head>
<body class="bg-slate-50 text-slate-800">
<header class="gradient text-white">
  <div class="max-w-6xl mx-auto px-6 py-20">
    <p class="uppercase tracking-[0.3em] text-green-200 text-sm mb-4">Computer Vision Project</p>
    <h1 class="text-5xl md:text-6xl font-extrabold leading-tight">4× Super-Resolution cGAN</h1>
    <p class="mt-6 text-xl text-slate-100 max-w-3xl leading-8">
      A conditional GAN that reconstructs high-resolution agricultural leaf images from low-resolution inputs.
      The model combines adversarial training, perceptual loss, and pixel-wise reconstruction loss to preserve
      fine textures and disease patterns critical for plant health analysis.
    </p>
    <div class="mt-8 flex flex-wrap gap-3">
      <span class="px-4 py-2 rounded-full bg-white/10 border border-white/20">4× Upscaling</span>
      <span class="px-4 py-2 rounded-full bg-white/10 border border-white/20">Conditional GAN</span>
      <span class="px-4 py-2 rounded-full bg-white/10 border border-white/20">VGG Perceptual Loss</span>
      <span class="px-4 py-2 rounded-full bg-white/10 border border-white/20">Agricultural Images</span>
    </div>
  </div>
</header>

<main class="max-w-6xl mx-auto px-6 py-12 space-y-20">
  <section class="grid md:grid-cols-4 gap-6 -mt-20">
    <div class="glass rounded-3xl shadow-xl p-6"><div class="text-3xl font-extrabold text-green-600"></div><div class="text-sm text-slate-600 mt-1">Resolution Enhancement</div></div>
    <div class="glass rounded-3xl shadow-xl p-6"><div class="text-3xl font-extrabold text-emerald-600">cGAN</div><div class="text-sm text-slate-600 mt-1">Generator + Discriminator</div></div>
    <div class="glass rounded-3xl shadow-xl p-6"><div class="text-3xl font-extrabold text-lime-600">VGG</div><div class="text-sm text-slate-600 mt-1">Perceptual Loss</div></div>
    <div class="glass rounded-3xl shadow-xl p-6"><div class="text-3xl font-extrabold text-teal-600">MAE</div><div class="text-sm text-slate-600 mt-1">Optimization Target</div></div>
  </section>

  <section>
    <h2 class="text-3xl font-bold mb-4">Project Overview</h2>
    <p class="text-lg text-slate-600 leading-8">
      This project addresses image super-resolution for agricultural leaf datasets. Low-resolution images
      are upscaled by a factor of four using a conditional GAN with a deep residual generator and a
      multi-scale discriminator. A hybrid objective combines adversarial loss, L1 reconstruction loss,
      and VGG-based perceptual loss to generate visually realistic and structurally accurate outputs.
    </p>
  </section>

  <section>
    <h2 class="text-3xl font-bold mb-8">Pipeline Architecture</h2>
    <div class="grid md:grid-cols-5 gap-4 text-center">
      <div class="bg-white rounded-2xl p-5 shadow">Low-Res Input</div>
      <div class="bg-white rounded-2xl p-5 shadow">Residual Generator</div>
      <div class="bg-white rounded-2xl p-5 shadow">4× Upsampling</div>
      <div class="bg-white rounded-2xl p-5 shadow">Multi-Scale Discriminator</div>
      <div class="bg-white rounded-2xl p-5 shadow">High-Res Output</div>
    </div>
  </section>

  
    <section>
      <h2 class="text-3xl font-bold mb-8">Real Results from the Notebook</h2>
      <p class="text-slate-600 mb-6 leading-7">
        Actual visual outputs extracted directly from the Jupyter notebook, including low-resolution inputs,
        generated super-resolved images, and side-by-side comparisons.
      </p>
      <div class="grid md:grid-cols-2 gap-6">
        <img src="notebook_image_1.png" class="rounded-2xl shadow-lg w-full" alt="Notebook output 1">
<img src="notebook_image_2.png" class="rounded-2xl shadow-lg w-full" alt="Notebook output 2">
      </div>
    </section>
    

  <section class="grid md:grid-cols-2 gap-6">
    <div class="bg-white rounded-3xl p-6 shadow-lg">
      <h3 class="text-2xl font-bold mb-4">Generator Architecture</h3>
      <p class="text-slate-600 leading-7">
        Residual blocks extract high-level features, followed by progressive upsampling layers that reconstruct
        high-frequency details such as leaf veins, lesions, and texture patterns.
      </p>
    </div>
    <div class="bg-white rounded-3xl p-6 shadow-lg">
      <h3 class="text-2xl font-bold mb-4">Discriminator Architecture</h3>
      <p class="text-slate-600 leading-7">
        A multi-scale discriminator evaluates local and global realism, encouraging outputs that are both
        perceptually convincing and statistically similar to real high-resolution images.
      </p>
    </div>
  </section>

  <section class="space-y-8">
    <h2 class="text-3xl font-bold">Key Code Snippets</h2>

    <div class="code-card rounded-3xl p-6 shadow-xl">
      <h3 class="text-xl font-bold mb-3 text-white">Generator Initialization</h3>
<pre><code>generator = Generator(upscale_factor=4)
discriminator = MultiScaleDiscriminator()</code></pre>
    </div>

    <div class="code-card rounded-3xl p-6 shadow-xl">
      <h3 class="text-xl font-bold mb-3 text-white">Perceptual Loss</h3>
<pre><code>vgg = VGGFeatureExtractor()
perceptual_loss = F.l1_loss(
    vgg(sr_images),
    vgg(hr_images)
)</code></pre>
    </div>

    <div class="code-card rounded-3xl p-6 shadow-xl">
      <h3 class="text-xl font-bold mb-3 text-white">Hybrid Generator Loss</h3>
<pre><code>g_loss = (
    adv_loss +
    lambda_l1 * l1_loss +
    lambda_perc * perceptual_loss
)</code></pre>
    </div>

    <div class="code-card rounded-3xl p-6 shadow-xl">
      <h3 class="text-xl font-bold mb-3 text-white">Training Loop</h3>
<pre><code>for lr_imgs, hr_imgs in train_loader:
    sr_imgs = generator(lr_imgs)
    d_loss = train_discriminator(...)
    g_loss = train_generator(...)</code></pre>
    </div>
  </section>

  <section class="grid lg:grid-cols-2 gap-10 items-start">
    <div>
      <h2 class="text-3xl font-bold mb-4">Expected Performance Trend</h2>
      <canvas id="perfChart"></canvas>
    </div>
    <div class="bg-white rounded-3xl p-8 shadow-lg">
      <h3 class="text-2xl font-bold mb-4">Optimization Strategies</h3>
      <ul class="space-y-3 text-slate-600">
        <li>• Test-Time Augmentation (TTA)</li>
        <li>• Progressive Training</li>
        <li>• Ensemble Methods</li>
        <li>• Fine-Tuning Strategy</li>
        <li>• Data Augmentation</li>
      </ul>
    </div>
  </section>

  <section>
    <h2 class="text-3xl font-bold mb-8">Technologies Used</h2>
    <div class="flex flex-wrap gap-3">
      <span class="px-4 py-2 bg-white rounded-full shadow">Python</span>
      <span class="px-4 py-2 bg-white rounded-full shadow">PyTorch</span>
      <span class="px-4 py-2 bg-white rounded-full shadow">Torchvision</span>
      <span class="px-4 py-2 bg-white rounded-full shadow">PIL</span>
      <span class="px-4 py-2 bg-white rounded-full shadow">NumPy</span>
      <span class="px-4 py-2 bg-white rounded-full shadow">Matplotlib</span>
    </div>
  </section>
</main>

<footer class="border-t border-slate-200 py-10 mt-12">
  <div class="max-w-6xl mx-auto px-6 text-slate-500">
    Built from the original Jupyter notebook and optimized for deployment as a static Hugging Face Space.
  </div>
</footer>

<script>
new Chart(document.getElementById('perfChart'), {
  type: 'line',
  data: {
    labels: ['Epoch 10', 'Epoch 20', 'Epoch 30', 'Epoch 40', 'Epoch 50'],
    datasets: [{ data: [0.032, 0.026, 0.021, 0.018, 0.015], tension: 0.35 }]
  },
  options: {
    plugins: {
      legend: { display: false },
      tooltip: {
        callbacks: {
          label: function(context) {
            return 'Validation MAE: ' + context.parsed.y.toFixed(3);
          }
        }
      }
    },
    scales: {
      y: {
        reverse: true,
        title: { display: true, text: 'Lower is Better (MAE)' }
      }
    }
  }
});
</script>
</body>
</html>