質問編集履歴
1
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -161,3 +161,209 @@
|
|
161
161
|
追加するものがあればするので
|
162
162
|
|
163
163
|
よろしくお願いします
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
```ここに言語を入力
|
168
|
+
|
169
|
+
import six.moves.urllib as urllib
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
```ここに言語を入力
|
174
|
+
|
175
|
+
>>> import os
|
176
|
+
|
177
|
+
>>> os.getcwd()
|
178
|
+
|
179
|
+
```
|
180
|
+
|
181
|
+
'/Users/yokookentarou'
|
182
|
+
|
183
|
+
```ここに言語を入力
|
184
|
+
|
185
|
+
try:
|
186
|
+
|
187
|
+
import urllib.request
|
188
|
+
|
189
|
+
except ImportError:
|
190
|
+
|
191
|
+
raise ImportError('You should use Python 3.x')
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
if not os.path.exists('./RoadDamageDataset.tar.gz'):
|
196
|
+
|
197
|
+
url_base = 'https://s3-ap-northeast-1.amazonaws.com/mycityreport/RoadDamageDataset.tar.gz'
|
198
|
+
|
199
|
+
urllib.request.urlretrieve(url_base, './RoadDamageDataset.tar.gz')
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
print("Download RoadDamageDataset.tar.gz Done")
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
else:
|
208
|
+
|
209
|
+
print("You have RoadDamageDataset.tar.gz")
|
210
|
+
|
211
|
+
```
|
212
|
+
|
213
|
+
You have RoadDamageDataset.tar.gz
|
214
|
+
|
215
|
+
```ここに言語を入力
|
216
|
+
|
217
|
+
if not os.path.exists('./trainedModels.tar.gz'):
|
218
|
+
|
219
|
+
url_base = 'https://s3-ap-northeast-1.amazonaws.com/mycityreport/trainedModels.tar.gz'
|
220
|
+
|
221
|
+
urllib.request.urlretrieve(url_base, './trainedModels.tar.gz')
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
print("Download trainedModels.tar.gz Done")
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
else:
|
230
|
+
|
231
|
+
print("You have trainedModels.tar.gz")
|
232
|
+
|
233
|
+
```
|
234
|
+
|
235
|
+
You have trainedModels.tar.gz
|
236
|
+
|
237
|
+
```ここに言語を入力
|
238
|
+
|
239
|
+
!tar -zxf ./RoadDamageDataset.tar.gz
|
240
|
+
|
241
|
+
!tar -zxf ./trainedModels.tar.gz
|
242
|
+
|
243
|
+
```
|
244
|
+
|
245
|
+
RoadDamageDataset/Muroran/JPEGImages/Muroran_20170907133426.jpg: (Empty error message)
|
246
|
+
|
247
|
+
tar: Error exit delayed from previous errors.
|
248
|
+
|
249
|
+
```ここに言語を入力
|
250
|
+
|
251
|
+
base_path = os.getcwd() + '/RoadDamageDataset/'
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
damageTypes=["D00", "D01", "D10", "D11", "D20", "D40", "D43", "D44"]
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
govs = ["Adachi", "Chiba", "Ichihara", "Muroran", "Nagakute", "Numazu", "Sumida"]
|
260
|
+
|
261
|
+
```
|
262
|
+
|
263
|
+
```ここに言語を入力
|
264
|
+
|
265
|
+
cls_names = []
|
266
|
+
|
267
|
+
total_images = 0
|
268
|
+
|
269
|
+
for gov in govs:
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
file_list = os.listdir(base_path + gov + '/Annotations/')
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
for file in file_list:
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
total_images = total_images + 1
|
282
|
+
|
283
|
+
if file =='.DS_Store':
|
284
|
+
|
285
|
+
pass
|
286
|
+
|
287
|
+
else:
|
288
|
+
|
289
|
+
infile_xml = open(base_path + gov + '/Annotations/' +file)
|
290
|
+
|
291
|
+
tree = ElementTree.parse(infile_xml)
|
292
|
+
|
293
|
+
root = tree.getroot()
|
294
|
+
|
295
|
+
for obj in root.iter('object'):
|
296
|
+
|
297
|
+
cls_name = obj.find('name').text
|
298
|
+
|
299
|
+
cls_names.append(cls_name)
|
300
|
+
|
301
|
+
print("total")
|
302
|
+
|
303
|
+
print("# of images:" + str(total_images))
|
304
|
+
|
305
|
+
print("# of labels:" + str(len(cls_names)))
|
306
|
+
|
307
|
+
```
|
308
|
+
|
309
|
+
---------------------------------------------------------------------------
|
310
|
+
|
311
|
+
UnicodeDecodeError Traceback (most recent call last)
|
312
|
+
|
313
|
+
<ipython-input-10-54a6927ce3e8> in <module>()
|
314
|
+
|
315
|
+
12 else:
|
316
|
+
|
317
|
+
13 infile_xml = open(base_path + gov + '/Annotations/' +file)
|
318
|
+
|
319
|
+
---> 14 tree = ElementTree.parse(infile_xml)
|
320
|
+
|
321
|
+
15 root = tree.getroot()
|
322
|
+
|
323
|
+
16 for obj in root.iter('object'):
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
/anaconda3/envs/TensorFlow2/lib/python3.6/xml/etree/ElementTree.py in parse(source, parser)
|
328
|
+
|
329
|
+
1194 """
|
330
|
+
|
331
|
+
1195 tree = ElementTree()
|
332
|
+
|
333
|
+
-> 1196 tree.parse(source, parser)
|
334
|
+
|
335
|
+
1197 return tree
|
336
|
+
|
337
|
+
1198
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
/anaconda3/envs/TensorFlow2/lib/python3.6/xml/etree/ElementTree.py in parse(self, source, parser)
|
342
|
+
|
343
|
+
595 # It can be used to parse the whole source without feeding
|
344
|
+
|
345
|
+
596 # it with chunks.
|
346
|
+
|
347
|
+
--> 597 self._root = parser._parse_whole(source)
|
348
|
+
|
349
|
+
598 return self._root
|
350
|
+
|
351
|
+
599 while True:
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
/anaconda3/envs/TensorFlow2/lib/python3.6/codecs.py in decode(self, input, final)
|
356
|
+
|
357
|
+
319 # decode input (taking the buffer into account)
|
358
|
+
|
359
|
+
320 data = self.buffer + input
|
360
|
+
|
361
|
+
--> 321 (result, consumed) = self._buffer_decode(data, self.errors, final)
|
362
|
+
|
363
|
+
322 # keep undecoded input until the next call
|
364
|
+
|
365
|
+
323 self.buffer = data[consumed:]
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 45: invalid start byte
|