質問編集履歴

1

追記

2018/04/19 02:12

投稿

trafalbad
trafalbad

スコア303

test CHANGED
File without changes
test CHANGED
@@ -52,4 +52,84 @@
52
52
 
53
53
  ParseError: not well-formed (invalid token): line 1, column 839
54
54
 
55
+
56
+
55
57
  ```
58
+
59
+
60
+
61
+ 解決
62
+
63
+ ```
64
+
65
+ # In[34]:
66
+
67
+
68
+
69
+
70
+
71
+ enc_train_file=[]
72
+
73
+ for i in train_file:
74
+
75
+ enc_train_file.append(Image.open(i).convert('RGB'))
76
+
77
+
78
+
79
+
80
+
81
+ # In[40]:
82
+
83
+
84
+
85
+
86
+
87
+ enc_test_file=[]
88
+
89
+ for i,v in enumerate(test_file):
90
+
91
+ if (not i % 5 == 0):
92
+
93
+ enc_test_file.append(Image.open(v).convert('RGB'))
94
+
95
+
96
+
97
+
98
+
99
+ # In[41]:
100
+
101
+
102
+
103
+
104
+
105
+ train_enc_img=[]
106
+
107
+ for i in enc_train_file:
108
+
109
+ img_bin = io.BytesIO() #メモリに保持してディレクトリ偽装みたいなことする
110
+
111
+ pil_img = i.save(img_bin,"JPEG") #PILで読み込む
112
+
113
+ img_bin.seek(0)
114
+
115
+ byteImg=img_bin.read()
116
+
117
+ data_bin=io.BytesIO(byteImg)
118
+
119
+ bin_img=data_bin.getvalue()
120
+
121
+ train_enc_img.append(base64.b64encode(bin_img))
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+ for i in train_enc_img:
130
+
131
+ with open('train.xml', "wb") as f:
132
+
133
+ f.write(i)
134
+
135
+ ```