teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードの追加、参考にしているサイト

2018/07/23 07:53

投稿

yokookentarou
yokookentarou

スコア11

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,57 @@
1
+ ```cls_names = []
2
+ total_images = 0
3
+ for gov in govs:
4
+
5
+ file_list = os.listdir(base_path + gov + '/Annotations/')
6
+
7
+ for file in file_list:
8
+
9
+ total_images = total_images + 1
10
+ if file =='.DS_Store':
11
+ pass
12
+ else:
13
+ infile_xml = open(base_path + gov + '/Annotations/' +file)
14
+ tree = ElementTree.parse(infile_xml)
15
+ root = tree.getroot()
16
+ for obj in root.iter('object'):
17
+ cls_name = obj.find('name').text
18
+ cls_names.append(cls_name)
19
+ print("total")
20
+ print("# of images:" + str(total_images))
21
+ print("# of labels:" + str(len(cls_names)))
22
+ コード
23
+ ```---------------------------------------------------------------------------
24
+ UnicodeDecodeError Traceback (most recent call last)
1
- ![イメージ説明]![イメージ説明](9c460afe7d113e28cbc5432298511266.png)
25
+ <ipython-input-43-73bb8957341c> in <module>()
26
+ 13 else:
27
+ 14 infile_xml = open(base_path + gov + '/Annotations/' +file)
28
+ ---> 15 tree = ElementTree.parse(infile_xml)
29
+ 16 root = tree.getroot()
30
+ 17 for obj in root.iter('object'):
31
+
32
+ /anaconda3/lib/python3.6/xml/etree/ElementTree.py in parse(source, parser)
33
+ 1194 """
34
+ 1195 tree = ElementTree()
35
+ -> 1196 tree.parse(source, parser)
36
+ 1197 return tree
37
+ 1198
38
+
39
+ /anaconda3/lib/python3.6/xml/etree/ElementTree.py in parse(self, source, parser)
40
+ 595 # It can be used to parse the whole source without feeding
41
+ 596 # it with chunks.
42
+ --> 597 self._root = parser._parse_whole(source)
43
+ 598 return self._root
44
+ 599 while True:
45
+
46
+ /anaconda3/lib/python3.6/codecs.py in decode(self, input, final)
47
+ 319 # decode input (taking the buffer into account)
48
+ 320 data = self.buffer + input
49
+ --> 321 (result, consumed) = self._buffer_decode(data, self.errors, final)
50
+ 322 # keep undecoded input until the next call
2
- ![イメージ説明](5a3d6b04d86e2113350130caa227f0db.png)
51
+ 323 self.buffer = data[consumed:]
52
+
53
+ UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 45: invalid start byte
54
+ コード
3
55
  ### 前提・実現したいこと
4
56
  python初心者です。
5
57
  GitHubから引用し。指示通り、jupyternotebookで動かしているのですが
@@ -26,4 +78,6 @@
26
78
  などを追加してみたのですがダメでした
27
79
  ### 補足情報(FW/ツールのバージョンなど)
28
80
 
29
- ここにより詳細な情報を記載してください。
81
+ ここにより詳細な情報を記載してください。
82
+ 参考にしているgithubです
83
+ https://github.com/sekilab/RoadDamageDetector/blob/master/RoadDamageDatasetTutorial.ipynb