0

My training data is imbalanced. So I decided to resample my dataset. I want to do slightly changes while resampling. I'd like to apply a horizontal flip and Gaussian filter to minority classes to make all classes equal.

To do so, I'd like to use pure image processing techniques to increase the number of my samples with the minority. To do that, I run this code in my classes which have less images

directory = ''

for file in os.listdir(directory):
img = cv2.imread(directory + file)
# horizontal_img = cv2.flip( img, 0 )
Flip_Horizontal = cv2.flip(img, 1) # 1 means Horizontal Flip

#saving now
cv2.imwrite(file + '_flip' + '.jpg', Flip_Horizontal)

However, I Have seen some tutorials are using Keras libraries to do image augmentation. Like following blog post:

https://www.pyimagesearch.com/2020/04/27/fine-tuning-resnet-with-keras-tensorflow-and-deep-learning/

In my case can I use the first technique (pure image processing= manual copy-pasting data with slight changes)? or should I use the libraries that are available in Keras or PyTorch?

nikki
  • 365
  • 4
  • 20
  • Torch offers a rich functionality for image augmentation through torchvision: https://pytorch.org/docs/stable/torchvision/transforms.html – ericstevens26101 Apr 29 '20 at 09:10
  • @ericstevens26101, what I was trying to ask was totally different, I want to manually do this by adding some filters and flipping pictures without using Keras or PyTorch libraries. Like the code that I used to read and flip my images in the above. – nikki Apr 29 '20 at 14:07

0 Answers0