1

I am working on classification of images breast cancer using DensetNet121 pretrained model. I want to apply data augmentation on the training data. I tried on the below code to augment the data using Keras and ImageDataGenerator. The data augmented but I don't know how to gel the labelled for each augmented image ?? Also I want to save each image in a specific iterated loop like aug_0_0, aug_0_1 and aug_0_2 but the data generated automatically by different numbers in names like aug_0_76768 and aug_0_23563. I want to stop the numbers which is automatically appears in the name of the augmented image.

My Question is How I get generate the label file for each augmented image ? and How to rename it and stop automatic appears of numbers ?

Code:

import glob
import cv2 
import os
from keras.preprocessing.image import ImageDataGenerator
import numpy as np
import matplotlib.pyplot as plt

string2 = [1000, 137, 166, 220, 226, 42, 49, 51, 55,
           66, 68, 750, 800, 850, 900, 950]
for f in string2:
    list2 = []
    normal_dir = 'D:\Images\Metodologia\SAUDAGoaVEIS\{}\Segmentadas'.format(
    f)
    dir1 = os.path.join(normal_dir, "*.png")
    datagen = ImageDataGenerator(
            rotation_range = 30, zoom_range = 0.02)           
    for img in glob.glob(dir1):
        cv_img = cv2.imread(img)
        cv_resize = cv2.resize(cv_img,(200,200))
        cv_norm_img = cv_resize/255.0
        break   
    cv_norm_img = np.array(cv_norm_img)
    input_batch = cv_norm_img.reshape((1,*cv_norm_img.shape))
    i = 0
    for output_batch in datagen.flow(input_batch,batch_size=1,
   save_to_dir='D:\Images\Metodologia\SAUDAGoaVEIS\{}\Segmentadas'.format(
   f),save_prefix='aug', save_format='png'):
        i+=1      
        if i > 0:
            break
Eda
  • 565
  • 1
  • 7
  • 18

0 Answers0