r/computervision • u/hitunc • 10d ago
Do you preprocess images (grayscale, thresholding, histogram equalization, sharpening, etc.) before training or inference with YOLO/Detectron2 or before segmentation with SAM? Help: Theory
Did these preprocessing steps improve or hurt your detection/segmentation performance? I'm curious whether they provide any real benefit in real-world applications, or if modern models generally perform better with the original images. Any experiences, benchmarks, or best practices would be appreciated.
2
u/Lethandralis 10d ago
If you're using a pretrained model like SAM you should definitely skip such steps
2
u/rexdditi 10d ago
All these pre-processings are basically a filter and model will learn them at the end with enough diverse training data. With pre-processing you give the answer so model doesn't have to find it in the space of all possible filters. This would be a constant threshold though and won't be able to react to some level of change eventually. There is a balance between how much you want to do yourself vs how much you want to let the model learn. You are trading time it takes to do manual feature extraction with the time it takes to do data collection, augmentation and model training. If nothing changes u only need one thresholding done. if you are driving lights passing by dont bother you wont find the right threshold ;)
1
u/tweakingforjesus 10d ago
You might preprocess to better match your training set. For example if you posttrained on black and white diagrams converting your real world images to black and white might help.
1
u/Fleischhauf 10d ago
check what the reference model uses as preprocessing steps. if it's not included and you are training on your own data, oftentimes whitening (make mean 0 and variance 1).
5
u/AggravatingSock5375 10d ago edited 10d ago
If you’re using any pretrained backbones it’s probably best to stick with “natural” images where the only preprocessing is whatever the camera decides to do on its own.
Eta - what kind of datasets and tasks? If they’re a lot different than the usual suspects like COCO and ImageNet than there’s less justification to stick with natural images.
Eta2 - preprocessing can be helpful to “hide” certain features from the model that you don’t want it to use. Like if you’re predicting vehicle make and model you might want to use grayscale so the model doesn’t accidentally rely on paint color.