Project
LivePlant Leaves cGAN
A 4x image super-resolution conditional GAN for agricultural leaf imagery — residual generators, multi-scale discriminators, and adversarial, perceptual (VGG), and L1 losses trained in PyTorch.
Low-resolution leaf images are a real problem in agricultural AI: field photos come off cheap cameras, drones, and phone uploads, and every downstream task — disease classification, growth monitoring, yield estimation — degrades when the input is a blur. This project builds a conditional GAN that upsamples agricultural leaf images 4x while reconstructing the detail a classifier would otherwise lose.
The generator uses residual blocks to hallucinate high-frequency detail, and a multi-scale discriminator that criticizes the output at several resolutions so the upscales stay locally consistent instead of producing artifacts that fool a single discriminator.
Approach
- Residual generator — residual blocks that learn the high-frequency residual between a low-res input and its high-res target, upsampled to 4x resolution.
- Multi-scale discriminators — critics at multiple resolutions, which forces the generator to produce sharpness that survives scrutiny at every scale.
- Three losses — adversarial loss for realism, perceptual loss from a VGG19 feature extractor so reconstructions match human-perceptual texture rather than pixel values, and L1 loss to anchor the output to the ground truth.
Tools
Implemented in PyTorch with torchvision for the VGG19 feature extractor and pretrained weights, OpenCV and PIL for image handling, NumPy for array work, and Matplotlib for comparing low-res, super-resolved, and ground-truth crops side by side. The perceptual loss was the difference-maker: pure adversarial training produced sharp but invented texture, while adding the VGG loss made reconstructions both sharp and faithful to the real leaf structure.