Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- NumPy
- 정보처리기사 c언어
- MySQL
- python
- programmers
- 가상환경
- 백준
- Join
- Algorithm
- 선그래프
- 데이터시각화
- type hint
- pandas
- Selenium
- aws jupyter notebook
- javascript
- 프로그래머스
- 알고리즘
- 알고리즘스터디
- queue
- 알고리즘 스터디
- String Method
- openCV
- dataframe
- 노마드코딩
- 코딩테스트
- 파이썬
- Stack
- Matplotlib
- 자료구조
Archives
- Today
- Total
조금씩 꾸준히 완성을 향해
[Yolov5 라벨링] xml 파일 txt 파일로 변경하기 (xml to txt) 본문
기존에 해놨던 이미지 라벨링을 그대로 사용해서 Yolov5로 돌리려고 하니 문제가 발생했다.
욜로에서는 라벨링 파일이 txt 형식이어야 한다는 것!
그래서 구글링 하던 중 xml to txt를 수월하게 해 주는 오픈 소스를 발견했다.
https://github.com/Isabek/XmlToTxt
GitHub - isabek/XmlToTxt: ImageNet file xml format to Darknet text format
ImageNet file xml format to Darknet text format. Contribute to isabek/XmlToTxt development by creating an account on GitHub.
github.com
▶ 먼저 저장소를 클론해 온 후 필요한 소스들을 설치한다.
git clone https://github.com/Isabek/XmlToTxt
pip install -r requirements.txt
▶ classes 파일을 열고 라벨링 한 class들을 적어 준다. (반드시 순서와 개수가 맞아야 에러가 나지 않는다.)

▶ xml to txt
python xmltotxt.py -xml [xml파일이 있는 폴더명] -out [변환된 txt파일을 저장할 폴더명]
▶ 변경 예시
Input xml file
<annotation>
<filename>image-0000016.jpg</filename>
<size>
<width>1920</width>
<height>1080</height>
</size>
<object>
<name>sedan</name>
<bndbox>
<xmin>75</xmin>
<ymin>190</ymin>
<xmax>125</xmax>
<ymax>210</ymax>
</bndbox>
</object>
</annotation>
Output text file
5 0.052083 0.185185 0.026042 0.018519
아주 간단하게 변경 완료 :)
