All Projects → zzl-pointcloud → Data_Augmentation_Zoo_for_Object_Detection

zzl-pointcloud / Data_Augmentation_Zoo_for_Object_Detection

Licence: other
Includes: Learning data augmentation strategies for object detection | GridMask data augmentation | Augmentation for small object detection in Numpy. Use RetinaNet with ResNet-18 to test these methods on VOC and KITTI.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Data Augmentation Zoo for Object Detection

tfboys
TensorFlow and Pytorch practice codes with purity and simplicity.
Stars: ✭ 34 (-73.02%)
Mutual labels:  objectdetection
torch-pitch-shift
Pitch-shift audio clips quickly with PyTorch (CUDA supported)! Additional utilities for searching efficient transformations are included.
Stars: ✭ 70 (-44.44%)
Mutual labels:  augmentation
Raspberry-Pi-Movidius-Person-Detector
Raspberry Pi Movidius Neural Compute Stick person detector installer
Stars: ✭ 20 (-84.13%)
Mutual labels:  objectdetection
textaugment
TextAugment: Text Augmentation Library
Stars: ✭ 280 (+122.22%)
Mutual labels:  augmentation
SSD Demo Android
基于 mxnet, 实现 ssd demo for android
Stars: ✭ 14 (-88.89%)
Mutual labels:  objectdetection
deeper-traffic-lights
[repo not maintained] Check out https://diffgram.com if you want to build a visual intelligence
Stars: ✭ 91 (-27.78%)
Mutual labels:  objectdetection
deep utils
An open-source toolkit which is full of handy functions, including the most used models and utilities for deep-learning practitioners!
Stars: ✭ 73 (-42.06%)
Mutual labels:  augmentation
DataAugmentationNMT
Data Augmentation for Neural Machine Translation
Stars: ✭ 26 (-79.37%)
Mutual labels:  augmentation
classification
Catalyst.Classification
Stars: ✭ 35 (-72.22%)
Mutual labels:  augmentation
IR-GAN
Augmenting Room Impulse Response
Stars: ✭ 21 (-83.33%)
Mutual labels:  augmentation
CAP augmentation
Cut and paste augmentation for object detection and instance segmentation
Stars: ✭ 93 (-26.19%)
Mutual labels:  augmentation
volumentations
Library for 3D augmentations
Stars: ✭ 111 (-11.9%)
Mutual labels:  augmentation
SQUAD2.Q-Augmented-Dataset
Augmented version of SQUAD 2.0 for Questions
Stars: ✭ 31 (-75.4%)
Mutual labels:  augmentation
mix3d
Mix3D: Out-of-Context Data Augmentation for 3D Scenes (3DV 2021 Oral)
Stars: ✭ 183 (+45.24%)
Mutual labels:  augmentation
ohsome2label
Historical OpenStreetMap Objects to Machine Learning Training Samples
Stars: ✭ 33 (-73.81%)
Mutual labels:  objectdetection
FAST-RIR
This is the official implementation of our neural-network-based fast diffuse room impulse response generator (FAST-RIR) for generating room impulse responses (RIRs) for a given acoustic environment.
Stars: ✭ 90 (-28.57%)
Mutual labels:  augmentation
discolight
discolight is a robust, flexible and infinitely hackable library for generating image augmentations ✨
Stars: ✭ 25 (-80.16%)
Mutual labels:  augmentation
rmpe dataset server
Realtime Multi-Person Pose Estimation data server. Used as a training and validation data provider in training process.
Stars: ✭ 14 (-88.89%)
Mutual labels:  augmentation
augmenty
Augmenty is an augmentation library based on spaCy for augmenting texts.
Stars: ✭ 101 (-19.84%)
Mutual labels:  augmentation
timber-ruby
🌲 Great Ruby logging made easy.
Stars: ✭ 155 (+23.02%)
Mutual labels:  augmentation

Data_Augmentation_Zoo_for_Object_Detection

Background

This project is built for testing multiple data augmentations for object detection:

  1. Zoph B, Cubuk E D, Ghiasi G, et al. Learning data augmentation strategies for object detection[J]. arXiv preprint arXiv:1906.11172, 2019. pdf | github

  2. Chen P. GridMask data augmentation[J]. arXiv preprint arXiv:2001.04086, 2020. pdf | github

  3. Kisantal M, Wojna Z, Murawski J, et al. Augmentation for small object detection[J]. arXiv preprint arXiv:1902.07296, 2019. pdf

Augmentation zoo for object Detection

Learning data augmentation strategies for object detection

Color Distortion

  • AutoContrast
  • Equalize: Equalize the image histogram
  • Posterize
  • Solarize: Invert all pixels above a threshold value of magniude
  • SolarizeAdd: For each pixel in the image that is less than 128, add an additional amount to it decided by the magnitude.
  • Color: Adjust the color balance of the image.
  • Contrast: Control the contrast of the image.
  • Brightness: Adjust the brightness of the image.
  • Sharpness: Adjust the sharpness of the image
  • Solarize_Only_BBoxes
  • Equalize_Only_Bboxes

ColourDistortion

Spatial Transformation

  • Cutout
  • BBox_Cutout
  • Flip
  • Rotate_BBox
  • TranslateX_BBox
  • TranslateY_BBox
  • ShearX_BBox
  • ShearY_BBox
  • TranslateX_Only_BBoxes
  • TranslateY_Only_BBoxes
  • Rotate_Only_BBoxes
  • ShearX_Only_BBoxes
  • ShearY_Only_BBoxes
  • Flip_Only_BBoxes
  • Cutout_Only_Bboxes

SpatialTransformation

Learned augmentation policy

  • Policy v0, v1, and custom were used in AutoAugment Detection Paper
  • Policy v2, v3 are additional policies that perform well on object detection
  • Policy v4 is the policy which mentioned in this paper, "the best"

How to use

Make sure the file "/augmentation_zoo/Myautoaugment_utils.py" is in project folder.

from Myautoaugment_utils import AutoAugmenter
# if you want to use the learned augmentation policy custom or v0-v4(v4 was recommended):
autoaugmenter = AutoAugmenter('v4')
# or if you want to use some spatial transformation or color distortion data augmentation,
# add the data augmentation method that you want to use to the policy_test in Myautoaugment_utils.py 
# and set the prob and magnitude. For excample:
# def policy_vtest():
#    policy = [
#        [('Color', 0.0, 6), ('Cutout', 0.6, 8)],
#    ]
#    return policy
autoaugmenter = AutoAugmenter('test')
# Input: 
#   Sample = {'img': img, 'annot': annots}
#   img = [H, W, C], RGB, value between [0,1]
#   annot = [xmin, ymin, xmax, ymax, label]
# Return:
#   Sample = {'img': img, 'annot': annots}
Sample = autoaugmenter(Sample)
# Use in Pytorch
dataset = Dataset(root, transform=transforms.Compose([autoaugmenter]))

GridMask

GridMask

Make sure the file "/augmentation_zoo/MyGridMask.py" is in project folder. And the input and output requirements are same as above

from MyGridMask import GridMask
GRID = False
GRID_ROTATE = 1
GRID_OFFSET = 0
GRID_RATIO = 0.5
GRID_MODE = 1
GRID_PROB = 0.5
Gridmask = GridMask(True, True, GRID_ROTATE,GRID_OFFSET,GRID_RATIO,GRID_MODE,GRID_PROB)
Sample = Gridmask(Sample)

Augmentation for small object detection

SmallobjectAugmentation

This method includes 3 Copy-Pasting Strategies:

  1. Pick one small object in an image and copy-paste it 1 time in random locations.
  2. Choose numerous small objects and copy-paste each of these 3 times in an arbitrary position.
  3. Copy-paste all small objects in each image 1 times in random places.

I code it in this way:

Algorithm: Augmentation for small object detection
Input: Sample x, Policy v, Threshold thresh, Prob prob
function SmallObjectAugmentation(x, v, thresh, prob)
	Perform the function with the probability of prob
	img, annots = x[‘img’], x[‘annot’]
	for annot in annots do
		if issmallobject(annot, thresh) do
			small_object_list.append(annot)
		end if
	end for
	copy_times and copy_object_num were decided by v
	shuffle the small_object_list
	for idx in range(copy_object_num) do
		to_be_copied_annot = small_object_list[idx]
		for _ in range(copy_times) do
			new_annot = create_copy_annot(to_be_copied_annot, annots)
			if new_annot is not None do
				img = add_patch_in_img(new_annot, to_be_copied_annot, img)
				annots.append(new_annot)
			end if
		end for
	end for
	return {‘img’: img, ‘annot’:annots}
End function 

To use this method, make sure the file "/augmentation_zoo/SmallObjectAugmentation.py" is in project folder. And the input and output requirements are same as above

"""   SMALL OBJECT AUGMENTATION   """
# Defaultly perform Policy 2, if you want to use   
# Policy 1, make SOA_ONE_OBJECT = Ture, or if you 
# want to use Policy 3, make SOA_ALL_OBJECTS = True
SOA_THRESH = 64*64
SOA_PROB = 1
SOA_COPY_TIMES = 3
SOA_EPOCHS = 30
SOA_ONE_OBJECT = False
SOA_ALL_OBJECTS = False
augmenter = SmallObjectAugmentation(SOA_THRESH, SOA_PROB, SOA_COPY_TIMES, SOA_EPOCHS, SOA_ALL_OBJECTS, SOA_ONE_OBJECT)
Sample = augmenter(Sample)

Experiment

I use the RetinaNet with ResNet-18, testing in VOC and KITTI. VOC_BATCH_SIZE = 8, KITTI_BATCH_SIZE = 24

DataSets No Augmentation Random Flip Autoaugmenter('v1') Autoaugmenter('v4') GridMask Small Object Augmentation
VOC 0.61492 0.63738 0.63651 0.62267 0.65605 0.63870
KITTI 0.60375 0.63077 0.58631 0.64347 0.71868 0.62622
KITTI Car van truck pedestrian Person_sitting cyclist Tram Misc mAP
No Augmenation 0.80197 0.64498 0.84922 0.52134 0.27078 0.50485 0.79602 0.47798 0.60375
Random Flip 0.82147 0.66679 0.85982 0.54333 0.35177 0.53576 0.80296 0.46428 0.63077
AutoAugmenter(‘v1’) 0.82838 0.55684 0.74368 0.55461 0.38256 0.48259 0.74964 0.39217 0.58631
AutoAugmenter(‘v4’) 0.82566 0.64851 0.87592 0.54426 0.40881 0.56872 0.80106 0.47480 0.64347
GridMask 0.85529 0.75980 0.91472 0.59351 0.51708 0.62842 0.86256 0.61804 0.71867
Small Object Augmentation 0.83064 0.60390 0.85146 0.55325 0.42748 0.50965 0.76821 0.46511 0.62621

My Contributions

  1. Realized the data preprocessing of VOC and KITTI in VocDataset/KittiDataset, prepare_data.py, which could be used by modifying the file path in config.py
  2. Realized Augmentation for small object Detection
  3. Modified the code of other papers and adjusted it to Numpy format
  4. Tested these methods on data sets VOC and KITTI
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].