Image Augmentation (Improve your Dataset) | with Imgaug, Opencv and Python

  Рет қаралды 18,121

Pysource

3 жыл бұрын

Source code and files: pysource.com/2021/06/08/image-augmentation-improve-your-dataset-with-imgaug/
This tutorial will help you improve your dataset if you have few images
➤ Full Video courses:
Object Detection: pysource.com/object-detection-opencv-deep-learning-video-course/
➤ Follow me on:
Instagram: pysource7
LinkedIn: www.linkedin.com/company/pysource
➤ For business inquiries:
pysource.com/contact
#opencv #python #ImageAugmentation

Пікірлер: 31
@alessandrocortese7748
@alessandrocortese7748 2 жыл бұрын
Fantastic tutorial, thanks a lot man !
@babuinba
@babuinba 3 жыл бұрын
Thanks much. Is there a way to detect side angle without eyes
@ahmadyoussef1754
@ahmadyoussef1754 Жыл бұрын
That is great, I have a question but how to do augmentation to labeled images in yolo format
@hackercop
@hackercop 2 жыл бұрын
Sir this was very helpful thanks. Have liked and subscribed
@RaviKumar-rf6qq
@RaviKumar-rf6qq Жыл бұрын
Dear Mr Sergio Canu Many thanks for your valuable information. Kindly give the code to save the augmented images into a folder. Thanks for your kind understanding and support.
@umairyounus2880
@umairyounus2880 3 жыл бұрын
Thanks for awesome tutorials, can you show us how to stream a video from opencv to rtsp?
@laranga7735
@laranga7735 Жыл бұрын
How can you move the bounding box along with the image rotation?
@helimehuseynova6631
@helimehuseynova6631 2 жыл бұрын
Hello, How can i place all augmented images into new folder? Thank you
@carlosjarquin5540
@carlosjarquin5540 3 жыл бұрын
How can I save those generated images?
@iyshwaryakannan6677
@iyshwaryakannan6677 Жыл бұрын
Hi, can you let me know how to save a video to my desktop using opencv
@handhikayp
@handhikayp 2 жыл бұрын
how to save the image after augmentation? thanks
@ortonhero7007
@ortonhero7007 Жыл бұрын
Awesome video but... i was expecting to show how to save the augmented images locally to the PC!
@mahmodaldahol
@mahmodaldahol 3 жыл бұрын
thank you very much
@gauravmaindola9560
@gauravmaindola9560 3 жыл бұрын
Hey great video! Is there anyway to apply this to images as well as the .txt files containing the bounding box coordinates?(asking this in reference to object detection)
@pysource-com
@pysource-com 3 жыл бұрын
Yes, when this library is integrated with the deep learning framework (for example keras or pytorch), it also applies the augmentation to the annotations. see more info on the official github release: github.com/aleju/imgaug
@gauravmaindola9560
@gauravmaindola9560 3 жыл бұрын
@@pysource-com Oh great thanks for your reply
@asmaagamal8821
@asmaagamal8821 Жыл бұрын
How can save generate image ?
@badiuzzamontashmatov5362
@badiuzzamontashmatov5362 3 жыл бұрын
Make please a video about Face_recognition
@helimehuseynova6631
@helimehuseynova6631 2 жыл бұрын
Hello, I am working with multi classification task. I have 3 folders. One of classes has few images and I want to increase that folder. My question is how can i augment that folder 10 times and save it at the same folder? Thank you
@shabirahmed6510
@shabirahmed6510 Жыл бұрын
use open cv to write images and save it to any folder u want
@aidanmacdougall5530
@aidanmacdougall5530 2 жыл бұрын
nice and to save them on a local drive?
@pysource-com
@pysource-com 2 жыл бұрын
normally this is integrated with the deep learning framework, so you shouldn't save them, especially because they have annotations associated, which will also match the augmentation.
@chibimoutain3429
@chibimoutain3429 3 ай бұрын
great tutorial! but can you finally answer those questions in comments? ;__; please that would be really helpful as well
@pr0fess0rop18
@pr0fess0rop18 Жыл бұрын
yo can anyone tell me how to actually store those augmented imgs as .jpeg
@pr0fess0rop18
@pr0fess0rop18 Жыл бұрын
import imgaug.augmenters as iaa import cv2 import os import glob images = [] images_path = glob.glob('Data\known\*.jpeg') for img_path in images_path: img = cv2.imread(img_path) images.append(img) augmentation = iaa.Sequential([ iaa.Rotate((-30,30)), iaa.Fliplr(0.5), iaa.Flipud(0.5), iaa.Affine(translate_percent={"x": (-0.2,-0.2), "y": (-0.2,-0.2)}, rotate=(-30,30), scale=(0.5, 1.5) ), iaa.Multiply((0.8, 1.2)), iaa.LinearContrast((0.6, 1.4)), iaa.Sometimes(0.5, iaa.GaussianBlur((0.0, 3.0)) ) ]) train_path = 'Data/known' #training images path augment_path = 'Data/augmented' #augmented images path name_list = [] #collection of names myList = os.listdir(train_path) #list full name of all image file # test_path = 'Data\unknown' #test images path- live_path = 'Data/live' #live images path # make array of training images and corresponding person name for person in myList: name_list.append(os.path.splitext(person)[0]) augmentation_counter = 0 for i in range(1): augmented_images = augmentation(images = images) counter = 0 for img in augmented_images: cv2.imshow("Image", img) cv2.imwrite(os.path.join(augment_path, f'{name_list[counter]}'+ '_' + f'{augmentation_counter}.jpeg'), img) cv2.waitKey(0) counter += 1 augmentation_counter += 1
@johnalfredcastaneda1596
@johnalfredcastaneda1596 2 жыл бұрын
I tried using imWrite instead of imshow as an attempt to save my files locally. However, each image being saved is overlapped by the next one. How can I save all of the photos altogether without them overlapping each other?
@pysource-com
@pysource-com 2 жыл бұрын
you need to save them with a different title. you can add a counter variable outside the loop and increase it by one on each loop: counter = 0 while True: counter += 1 cv2.imwrite(str(counter) + ".jpg", frame)
@johnalfredcastaneda1596
@johnalfredcastaneda1596 2 жыл бұрын
@@pysource-com is this correct? please correct me if im wrong #dataset and augmentation code counter = 0 while True: augmented_images = augmentation(images=images) for img in augmented_images: counter += 1 cv2.imwrite(str(counter) + ".jpg", frame) cv2.imwrite('Desktop/WartyAugmented/warty.png' ,img) #desired save location cv2.waitKey(0) also if this works, how do i limit the number of images that the augmentation will generate? thank you in advance
@chowdhurymilon3079
@chowdhurymilon3079 2 жыл бұрын
@@johnalfredcastaneda1596 Hi, did you solve this problem?
@pr0fess0rop18
@pr0fess0rop18 Жыл бұрын
@@johnalfredcastaneda1596 use for loop instead of while loop.... augmentation_counter = 0 # the current loop of augmentation indicator for i in range(10): # desired amount of times you need to augment augmented_images = augmentation(images = images) counter = 0 # counter representing the index that distinguishes the 3 dogs for img in augmented_images: cv2.imshow("Image", img) cv2.imwrite(f'Data\augmented\{name_list[counter]}{augmentation_counter}.jpeg', img) cv2.waitKey(0) counter += 1 augmentation_counter += 1
@pr0fess0rop18
@pr0fess0rop18 Жыл бұрын
cv2.imwrite(os.path.join(augment_path, f'{name_list[counter]}'+ '_' + f'{augmentation_counter}.jpeg'), img) #use this actually no the imwrite code in previous comment