Making synthetic cell images to help a classifier learn from only 150 pictures
Deep learning needs a lot of examples, and medical images are hard to collect. We had about 150 microscope pictures of benign and malignant cells, far too few for a modern classifier to learn well. In this paper we describe SynCGAN, a way to generate extra, realistic-looking cell images, and we show that three standard classifiers score higher on our test images when trained with them.
The problem
The images come from fine needle aspiration cytology (FNAC), a test in which a thin needle takes a few cells from a lump and a doctor examines them under a microscope. Our samples were collected at Theism Medical Diagnostics Centre in Kolkata with an Olympus microscope at 40× magnification. We collected around 156 images, 77 benign and 79 malignant, and used 150 of them, 75 per class.
The usual remedy for small data is augmentation, which means making new training examples from the old ones, for example by flipping or rotating the pictures or adding noise. A newer option is a generative adversarial network, or GAN. A GAN has two parts that compete. A generator draws pictures and a discriminator tries to tell them from real ones, and both improve as they play. Asked to draw a full microscope image from scratch, though, a GAN has too much to guess. Every pixel has three colour values, each with 256 possible levels.
The idea
We split the drawing into an easy step and a guided step. A black-and-white mask that marks where the nuclei sit is much simpler to produce, because every pixel is just on or off. So we first make masks, then paint a cell image on top of each one. A GAN that receives a guide like this is called a conditional GAN, and the mask is its prior, meaning the information it starts from.

How it works
The pipeline has three phases.
- Masks from real images. No one drew masks by hand. We stretch the contrast, convert to grey, apply adaptive thresholding, and then use Gaussian mixture clustering to separate nuclei from red blood cells and cytoplasm that have similar local contrast.
- Mask to image. The conditional GAN follows the pix2pix design. Its generator is a UNet-like network that upsamples with bilinear interpolation, because transposed convolutions leave checkerboard artifacts. Its discriminator is a PatchGAN. The generator is trained against both the discriminator and a mean squared error loss on the real image, weighted by 100, a value chosen on a small validation set.
- New masks per class. Two further GANs, one for benign and one for malignant, learn to produce masks from random noise. Their masks feed the trained conditional GAN, which paints the synthetic samples.

Training a GAN on so few masks was hard. The discriminator became too strong and stopped the generator from learning, so we used label smoothing, with real labels drawn between 0.9 and 1 and fake labels between 0 and 0.1. We also flipped real and fake labels at random iterations. The conditional GAN trained for up to 200 epochs and the mask GANs for about 1600, on a single Nvidia GTX 1060.

What we found
We kept 75 images per class and split them 3:1:1 into 90 training, 30 validation and 30 test images. We generated twice as many synthetic training images as real ones, 180 in all (Table 1). Then we trained ResNet-152, DenseNet-161 and Inception-V3 and compared test accuracy.
Adding SynCGAN images raised accuracy for all three: ResNet-152 from 73.33% to 76.67%, DenseNet-161 from 80.00% to 86.67%, and Inception-V3 from 73.33% to 80.00% (Table 2).
Results in more detail
Table 2 is the main comparison. Each row is one classifier and each column is a different training set. Orig is the 90 real training images only. Orig+Prop adds the SynCGAN images. Orig+Trad adds copies made by traditional augmentation, which here means random horizontal and vertical flips, random rotation and added Gaussian noise. Orig+Trad+Prop adds both. All numbers are accuracy on the 30 test images.
| Classifier | Orig | Orig+Prop | Orig+Trad | Orig+Trad+Prop |
|---|---|---|---|---|
| ResNet-152 | 73.33 | 76.67 | 70.00 | 76.67 |
| DenseNet-161 | 80.00 | 86.67 | 83.33 | 84.67 |
| Inception-V3 | 73.33 | 80.00 | 63.33 | 76.67 |
The paper says SynCGAN augmentation has a higher impact than traditional augmentation, which had a smaller effect and not always a helpful one. It lowered ResNet-152 to 70.00% and Inception-V3 to 63.33%, and raised DenseNet-161 to 83.33%. When we combined traditional augmentation with SynCGAN data, the result was at par with SynCGAN alone or lower: 76.67%, 84.67% and 76.67% for the three classifiers (Table 2).
The second comparison in Table 3 is the control experiment. The plain GAN had a generator and discriminator similar to ours, for a fair comparison, but it drew images directly with no mask to guide it. The column Prop trains on SynCGAN images alone, GAN trains on plain-GAN images alone, and Orig+GAN adds the plain-GAN images to the real ones.
| Classifier | Orig | Prop | Orig+Prop | GAN | Orig+GAN |
|---|---|---|---|---|---|
| ResNet-152 | 73.33 | 73.33 | 76.67 | 50.00 | 63.33 |
| DenseNet-161 | 80.00 | 63.33 | 86.67 | 50.00 | 60.00 |
| Inception-V3 | 73.33 | 66.67 | 80.00 | 56.67 | 66.67 |
Trained on plain-GAN images alone, the three classifiers reach 50.00%, 50.00% and 56.67%, and with the real images added 63.33%, 60.00% and 66.67%. In every row both plain-GAN columns are below the column of real images alone. Trained on SynCGAN images alone, ResNet-152 matches its real-only score of 73.33%, while DenseNet-161 and Inception-V3 reach 63.33% and 66.67% (Table 3). Real and synthetic images together do better than either alone, which is the Orig+Prop column.
We think the plain GAN fails because predicting every pixel's colour is a hard problem. Each pixel has three channels with 256 possible values each, so the output space is enormous. A black-and-white mask is far easier to predict, since each pixel is on or off, and the shape of the nuclei in the mask also carries information about the class, benign or malignant. In our ablation studies, outputs without a prior were of very poor quality. We could also have guided the conditional GAN with just a class label, but a mask is richer and gives more variety in the synthetic set.
A few training details matter for the numbers. The conditional GAN trained for at most 200 epochs, and we kept the model with the lowest generator loss on the validation images. The mask GANs trained for almost 1600 epochs, until their generator loss levelled off. All runs used the Adam optimiser on one Nvidia GTX 1060.
Other groups had already used GANs to augment medical data, and the paper reviews them. One liver-lesion study found a DCGAN did better than an ACGAN. Another used conditional GANs to turn tumour labels into brain MRI scans. Others simulated ultrasound images and skin lesions. In the brain study, adding synthetic scans to real ones improved tumour segmentation, which is the same idea we test for classification.
Discussion
We conclude that learnable segmentation masks can act as class-specific priors that guide a conditional GAN, and that the images it paints improve ResNet-152, DenseNet-161 and Inception-V3 on FNAC cytology images. In the abstract we describe the improvement as significant. We see the reason in the guidance. A GAN does much better with a simple guide than with none, and the guide does not have to be perfect. Detailed pixel labels were too costly to draw for every image, and rough masks from an unsupervised method were enough to make the generated images useful.
The paper states several limits. The method depends heavily on how the masks are produced. Ours come from one unsupervised recipe for finding nuclei, so we suggest trying other nuclei segmentation methods. Training a GAN on so few masks was hard, because the discriminator became too strong, and label smoothing and random label flipping were needed to give the generator room to learn. We mention that other GAN variants, such as the Wasserstein GAN, could improve results further. The test set has 30 images (Table 1), and all the images are FNAC samples collected at one centre.
For the future we suggest extending the approach to other kinds of cytological data.
Sources
The figures and tables listed here are taken from the paper cited at the top of this page; the numbers quoted in the text come from it too.
- Figures: Fig. 1, Fig. 2, Fig. 3
- Tables: Table 1: number of original and synthetic images in the training, validation and test sets; Table 2: test accuracy of each classifier with SynCGAN and traditional augmentation; Table 3: test accuracy with SynCGAN images compared with a plain GAN control
Acknowledgements
This work is funded by the SERB (DST), Govt. of India sponsored project (order no. EEQ/2018/000963 dated 22/03/2019). The authors are thankful to Theism Medical Diagnostics Centre, Kolkata, West Bengal, India, for providing the cytology samples, and to the Centre for Microprocessor Application for Training, Education, and Research, Jadavpur University, for providing additional infrastructure for the research.
Cite the paper
S Dey, S Das, Swarnendu Ghosh, S Mitra, S Chakrabarty, N Das (2019). SynCGAN: Using learnable class specific priors to generate synthetic data for improving classifier performance on cytological images. 7th National Conference on Computer Vision, Pattern Recognition, Image Processing & Graphics (NCVPRIPG), pp. 32–42 · Springer.
@inproceedings{dey2019syncgan,
author = {Dey, S and Das, S and Ghosh, Swarnendu and Mitra, S and Chakrabarty, S and Das, N},
title = {{SynCGAN:} Using learnable class specific priors to generate synthetic data for improving classifier performance on cytological images},
booktitle = {7th National Conference on Computer Vision, Pattern Recognition, Image Processing & Graphics (NCVPRIPG)},
pages = {32--42},
publisher = {Springer},
year = {2019},
doi = {10.1007/978-981-15-8697-2_3}
}