-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data Augmentation + Dán nhãn cho ảnh
52 lines (49 loc) · 2.98 KB
/
Data Augmentation + Dán nhãn cho ảnh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#chuẩn bị các tập generator cho train và test
image_generator = ImageDataGenerator(dtype='float32',
horizontal_flip=True,
vertical_flip=True,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
data_format='channels_last',
fill_mode='nearest',
shear_range=0.2
)
train_generator= image_generator.flow_from_dataframe(dataframe=train_1,
directory='../input/siim-isic-melanoma-classification/jpeg/train',
x_col= 'image_name',
y_col='benign_malignant',
color_mode='rgb',
class_mode='binary', #this will return one_hot encode labels
target_size=(256,256),
seed=42,
batch_size=16,
shuffle=True,
interpolation='nearest'
)
validation_generator= image_generator.flow_from_dataframe(dataframe=validation_1,
directory='../input/siim-isic-melanoma-classification/jpeg/train',
x_col= 'image_name',
y_col='benign_malignant',
color_mode='rgb',
class_mode='binary',
target_size=(256,256),
batch_size=16,
seed=42,
shuffle=True,
interpolation='nearest'
)
#tập test:
image_generator_1 = ImageDataGenerator(rescale=1/255.,
dtype='float16'
)
test_generator= image_generator_1.flow_from_dataframe(test_raw,
directory='../input/siim-isic-melanoma-classification/test',
x_col='image_name',
class_mode=None,
color_mode='rgb',
target_size=(256,256),
batch_size=32,
seed=42,
shuffle= False,
interpolation='nearest'