質問編集履歴
1
プログラム(前処理)を追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,6 +18,66 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
+
■プログラム(前処理)
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
v_image = []
|
26
|
+
|
27
|
+
v_label = []
|
28
|
+
|
29
|
+
for index, name in enumerate(folder):
|
30
|
+
|
31
|
+
dir = TRAIN_PATH + "\" + name
|
32
|
+
|
33
|
+
files = glob.glob(dir + "\*.png")
|
34
|
+
|
35
|
+
print(dir)
|
36
|
+
|
37
|
+
for i, file in enumerate(files):
|
38
|
+
|
39
|
+
if COLOR_CHANNEL == 1:
|
40
|
+
|
41
|
+
img = load_img(file, color_mode = "grayscale", target_size=(INPUT_IMAGE_SIZE, INPUT_IMAGE_SIZE))
|
42
|
+
|
43
|
+
elif COLOR_CHANNEL == 3:
|
44
|
+
|
45
|
+
img = load_img(file, color_mode = "rgb", target_size=(INPUT_IMAGE_SIZE, INPUT_IMAGE_SIZE))
|
46
|
+
|
47
|
+
array = img_to_array(img)
|
48
|
+
|
49
|
+
v_image.append(array)
|
50
|
+
|
51
|
+
v_label.append(index)
|
52
|
+
|
53
|
+
v_image = np.array(v_image)
|
54
|
+
|
55
|
+
v_label = np.array(v_label)
|
56
|
+
|
57
|
+
v_image = v_image.astype('float32')
|
58
|
+
|
59
|
+
v_image = v_image / 255.0
|
60
|
+
|
61
|
+
v_label = np_utils.to_categorical(v_label, CLASS_NUM)
|
62
|
+
|
63
|
+
train_images, test_images, train_labels, test_labels = train_test_split(v_image, v_label, test_size=0.20)
|
64
|
+
|
65
|
+
train_images2 = np.squeeze(train_images)
|
66
|
+
|
67
|
+
test_images2 = np.squeeze(test_images)
|
68
|
+
|
69
|
+
print(train_images2.shape)
|
70
|
+
|
71
|
+
print(test_images2.shape)
|
72
|
+
|
73
|
+
#(160, 28, 28)
|
74
|
+
|
75
|
+
#(40, 28, 28)
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
```
|
80
|
+
|
21
81
|
|
22
82
|
|
23
83
|
■プログラム(モデル)
|