Skip to content

OsamaMazhar/Random-Shadows-Highlights

Repository files navigation

Random Shadows and Highlights

This repo has the source code for the paper: Random Shadows and Highlights: A new data augmentation method for extreme lighting conditions.

Example:

from RandomShadowsHighlights import RandomShadows

 transform = transforms.Compose([
   transforms.RandomHorizontalFlip(),
   RandomShadows(p=0.8, high_ratio=(1,2), low_ratio=(0,1), left_low_ratio=(0.4,0.8),
                 left_high_ratio=(0,0.3), right_low_ratio=(0.4,0.8), right_high_ratio=(0,0.3)),
   transforms.ToTensor(),
   transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
 ])

If you find this code useful for your research, please consider citing:

@Misc{Mazhar2021arXiv,
  author  = {Mazhar, Osama and Kober, Jens},
  note    = {arXiv:2101.05361 [cs.CV]},
  title   = {{Random Shadows and Highlights}: A New Data Augmentation Method for Extreme Lighting Conditions},
  year    = {2021},
  code    = {https://github.com/OsamaMazhar/Random-Shadows-Highlights},
  file    = {https://arxiv.org/pdf/2101.05361.pdf},
  project = {OpenDR},
  url     = {https://arxiv.org/abs/2101.05361},
}

Requirements:

torch, torchvision, numpy, cv2, PIL, argparse

In case you want to use Disk-Augmenter for comparison, then install scikit-learn as well.

Steps:

To test on TinyImageNet, the dataset needs to be converted into PyTorch dataset format. This can be done by following instructions on this repo.

Also, for EfficientNet, install EfficientNet-PyTorch from here.

To start training, use the following command:

python main.py --model_dir outputs --filename output.txt --num_epochs 20 --model_name EfficientNet --dataset TinyImageNet

For CIFAR10 or CIFAR100, use argument --dataset CIFAR10 or --dataset CIFAR100.

To train on "AlexNet", use --model_name AlexNet.

If you have any questions about this code, please do not hesitate to contact me here.

About

A new data augmentation method for extreme lighting conditions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages