AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.57k stars 7.95k forks source link

Random removal of textures during data-augmentation or use Stylized-ImageNet +2.9 mAP@0.5 #3320

Open AlexeyAB opened 5 years ago

AlexeyAB commented 5 years ago

image

image


Random removal of textures during data-augmentation - something like Stylized-ImageNet, just we remove textures instead of changing then. Try to use something like Blur-then-sharpen: https://docs.opencv.org/master/d1/d10/classcv_1_1MatExpr.html#details

Mat blurred; double sigma = 1, threshold = 5, amount = 1;
GaussianBlur(img, blurred, Size(), sigma, sigma);
Mat lowContrastMask = abs(img - blurred) < threshold;
Mat sharpened = img*(1+amount) + blurred*(-amount);
img.copyTo(sharpened, lowContrastMask);

Based on articles:

LukeAI commented 4 years ago

Maybe more useful repo: https://github.com/bethgelab/stylize-datasets A generalisation of the Imagenet repo above for styling arbitrary datasets.

AlexeyAB commented 4 years ago

@LukeAI Why is it better?

LukeAI commented 4 years ago

I haven't used it but it works with arbitrary datasets, not just Imagenet.

AlexeyAB commented 4 years ago

Implemented bilateralFilter-bluring - it keeps details, but removes textures. It randomly alternates between blurry and non-blurry images, so that the textures will not be completely lost: https://github.com/AlexeyAB/darknet/commit/142fcdeb1e53ec78ec35d98503726075bd721a9b

You can use (only if Darknet is compiled with OpenCV):

[net]
blur=1

So will be applied cv::bilateralFilter(src, dst, ksize, 75, 75); - by default ksize=17


image


image


image

924175302 commented 4 years ago

@AlexeyAB Hello, I want to experiment with this effect on my data set. How can I output a randomly deleted texture image just like you? Because I want to compare the experimental results on my data with the original image and the randomly deleted texture image, what are the specific implementation steps, I hope you can answer

AlexeyAB commented 4 years ago

@924175302 Hi,

Set in cfg-file and train your model:

[net]
blur = 10