質問編集履歴
1
コメントありがとうございます。エラー全文そしてインデントも追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,79 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
+
TypeError Traceback (most recent call last)
|
16
|
+
|
17
|
+
<ipython-input-2-e1965da6b250> in <module>
|
18
|
+
|
19
|
+
29 xy = (X_train, X_test, y_train, y_test)
|
20
|
+
|
21
|
+
30
|
22
|
+
|
23
|
+
---> 31 plt.imshow(X_test)
|
24
|
+
|
25
|
+
32 plt.show()
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
~\anaconda3\lib\site-packages\matplotlib\pyplot.py in imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, filternorm, filterrad, resample, url, data, **kwargs)
|
30
|
+
|
31
|
+
2722 filternorm=True, filterrad=4.0, resample=None, url=None,
|
32
|
+
|
33
|
+
2723 data=None, **kwargs):
|
34
|
+
|
35
|
+
-> 2724 __ret = gca().imshow(
|
36
|
+
|
37
|
+
2725 X, cmap=cmap, norm=norm, aspect=aspect,
|
38
|
+
|
39
|
+
2726 interpolation=interpolation, alpha=alpha, vmin=vmin,
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
~\anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, data, *args, **kwargs)
|
44
|
+
|
45
|
+
1445 def inner(ax, *args, data=None, **kwargs):
|
46
|
+
|
47
|
+
1446 if data is None:
|
48
|
+
|
49
|
+
-> 1447 return func(ax, *map(sanitize_sequence, args), **kwargs)
|
50
|
+
|
51
|
+
1448
|
52
|
+
|
53
|
+
1449 bound = new_sig.bind(ax, *args, **kwargs)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
~\anaconda3\lib\site-packages\matplotlib\axes\_axes.py in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, filternorm, filterrad, resample, url, **kwargs)
|
58
|
+
|
59
|
+
5521 resample=resample, **kwargs)
|
60
|
+
|
61
|
+
5522
|
62
|
+
|
63
|
+
-> 5523 im.set_data(X)
|
64
|
+
|
65
|
+
5524 im.set_alpha(alpha)
|
66
|
+
|
67
|
+
5525 if im.get_clip_path() is None:
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
~\anaconda3\lib\site-packages\matplotlib\image.py in set_data(self, A)
|
72
|
+
|
73
|
+
700 if (self._A.dtype != np.uint8 and
|
74
|
+
|
75
|
+
701 not np.can_cast(self._A.dtype, float, "same_kind")):
|
76
|
+
|
77
|
+
--> 702 raise TypeError("Image data of dtype {} cannot be converted to "
|
78
|
+
|
79
|
+
703 "float".format(self._A.dtype))
|
80
|
+
|
81
|
+
704
|
82
|
+
|
83
|
+
|
84
|
+
|
15
85
|
TypeError: Image data of dtype object cannot be converted to float
|
86
|
+
|
87
|
+
|
16
88
|
|
17
89
|
|
18
90
|
|
@@ -44,23 +116,23 @@
|
|
44
116
|
|
45
117
|
for index, classlabel in enumerate(classes):
|
46
118
|
|
47
|
-
|
119
|
+
,,,,photos_dir = "./" + classlabel
|
48
120
|
|
49
|
-
files = glob.glob(photos_dir + "/*.jpg")
|
121
|
+
,,,,files = glob.glob(photos_dir + "/*.jpg")
|
50
122
|
|
51
|
-
for i, file in enumerate(files):
|
123
|
+
,,,,for i, file in enumerate(files):
|
52
124
|
|
53
|
-
if i >= 500: break
|
125
|
+
,,,,,,,,if i >= 500: break
|
54
126
|
|
55
|
-
image = Image.open(file)
|
127
|
+
,,,,,,,,image = Image.open(file)
|
56
128
|
|
57
|
-
image = image.convert("RGB")
|
129
|
+
,,,,,,,,image = image.convert("RGB")
|
58
130
|
|
59
|
-
image = image.resize((image_size, image_size))
|
131
|
+
,,,,,,,,image = image.resize((image_size, image_size))
|
60
132
|
|
61
|
-
X.append(image)
|
133
|
+
,,,,,,,,X.append(image)
|
62
134
|
|
63
|
-
Y.append(index)
|
135
|
+
,,,,,,,,Y.append(index)
|
64
136
|
|
65
137
|
|
66
138
|
|