Sewer defect classification on imbalanced data
Can GAN-generated images fix extreme class imbalance in sewer inspection? An honest negative result, and a labelling problem found on the way.
- result
- Negative result on GANs, root cause found in the labels
- role
- ML research intern, Veolia Research
- stack
- Computer vision, generative models (GAN), imbalanced classification
- 23defect types in the inspection dataset, from real sewer pipes
- 230,000+images between the most common and the rarest defect class
- 4training setups compared: raw, standard augmentation, GAN, both
- 0.31 → 0.59recall on the rare class with standard augmentation. GAN images made it worse
Problem
Sewer pipes are inspected by driving a camera robot through them while an expert watches and notes every defect. It is slow and tiring, so Veolia wanted a classifier. The obstacle is the data: some defects appear in hundreds of thousands of images and others in a few thousand, and a model learns to ignore what it rarely sees.
The question
Can a GAN generate realistic images of a rare defect, and does adding them to the training set make the classifier better at that defect? As far as we knew, nobody had tried this on sewer inspection data.
What I did
| Step | What happened |
|---|---|
| 1. Generate | Trained a balancing GAN (BAGAN: an autoencoder, then a class-conditional generator) on a benchmark first, then on the sewer images |
| 2. Hit a wall | On the raw data the GAN collapsed and produced nothing usable for the rare class |
| 3. Look at the data | Went through the rare class image by image: many samples did not show the defect they were labelled with |
| 4. Clean and rebalance | Removed the wrong labels by hand, under-sampled common classes, augmented the rare one. The GAN then trained and produced realistic images |
| 5. Test the idea | Trained four classifiers and compared them on the rare class, judged by recall and F1: missing a real defect costs more than a false alarm |
Result
| Trained on | Recall, rare class |
|---|---|
| Original data | 0.31 |
| Standard augmentation | 0.59 |
| GAN images | 0.11 |
| Standard + GAN | about 0.01 |
On the common classes all four setups scored the same, about 0.6.
The generated images looked right and still hurt the classifier. My explanation in the thesis: the GAN reproduced the look of a sewer pipe but not the fine detail that defines the defect (the generated “rats” had no clear legs, eyes or heads), so the classifier learned a blurred version of the class.
What I took from it
- Look at the data before tuning the model. The most useful finding of the project was upstream: the rare class was full of wrong labels, and no model could have fixed that.
- Report the negative result. “Realistic to the eye” is not the same as “useful for training”, and the simple method won.
- I still work this way in inspection projects, including semiconductor defect detection.
Master’s thesis, written during a research internship at Veolia Research & Innovation (France), 2022.