Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations - Yolo txt to xml format #155

Open
groot-1313 opened this issue Feb 20, 2018 · 12 comments
Open

Annotations - Yolo txt to xml format #155

groot-1313 opened this issue Feb 20, 2018 · 12 comments

Comments

@groot-1313
Copy link

Is there a script available to convert annotations in the YOLO txt format to the xml format accepted by the code?

@LucasVandroux
Copy link

The XML format accepted by the code is the Pascal VOC format. I don't know what you mean by the YOLO TXT format.

Personally, I am using the vod-converter to go from the KITTI format (.txt) to the Pascal VOC format (.xml).

@experiencor
Copy link
Owner

@groot-1313 Sorry I don't know of anything. Welcome your contribution if you can find or write one.

@FabianHeinemann
Copy link

I used labelImg which allows to browse through a set of images and create XML annotation files, which work for YOLO:
https://github.com/tzutalin/labelImg

@jerevon
Copy link

jerevon commented Aug 22, 2018

@FabianHeinemann do you need to convert .xml files from LabelImg to .txt file which used for yolo?

@imagineazhar
Copy link

@richardgohth
Copy link

@FabianHeinemann do you need to convert .xml files from LabelImg to .txt file which used for yolo?

hi
I need the other way around, from txt to xml
is there such a convertor?
thanks

@nourhanTr
Copy link

Hello, did you find a solution to transfer from .txt (YOLO format) to XML format?

@richardgohth
Copy link

cat /deepbin/txt2xml
#!/bin/csh -f
set f = $1
set ff = echo $f | cut -d"/" -f2 | sed 's/.txt$//'
echo $ff
if ( ! -e $ff.jpg ) then
echo does not exist
continue
endif
set wh = xli -identify $ff.jpg | cut -d" " -f4 | tr "x" " "
echo $wh
set aoi = cat $f
echo $aoi
if ( "$aoi" == "") continue
set cleft = echo "$aoi[2] * $wh[1]" | bc | sed 's/\..*$//'
set ctop = echo "$aoi[3] * $wh[2]" | bc | sed 's/\..*$//'
set width = echo "$aoi[4] * $wh[1]" | bc| sed 's/\..*$//'
set height = echo "$aoi[5] * $wh[2]" | bc| sed 's/\..*$//'
echo $cleft $ctop $width $height
@ hwidth = ( $width / 2 )
@ hheight = ( $height / 2 )
@ left = $cleft - $hwidth
@ right = $cleft + $hwidth
@ bot = $ctop + $hheight
@ top = $ctop - $hheight
echo $left $right $top $bot
#echo enter to continue
#set i =<$
#1 - roi file name
set roi = echo 0 $left $right $top $bot

set ifn = $ff.jpg
set xfn = $ff.xml
echo ifn $ifn
set w = xli -identify $ifn | cut -d" " -f4 | cut -d"x" -f1
set h = xli -identify $ifn | cut -d" " -f4 | cut -d"x" -f2
echo '' > $xfn
echo ' JPEGImages' >> $xfn
echo '' " $ifn " >> $xfn
echo '' " $ifn " >> $xfn
echo ' . ' >> $xfn
echo ' Unknown ' >> $xfn
echo " $w $h 1 " >> $xfn
echo ' 0 plate Unspecified 0 0 ' >> $xfn
echo " $roi[2] $roi[4] $roi[3] $roi[5] " >> $xfn

@richardgohth
Copy link

I wrote some csh scripts, maybe above is it

@nourhanTr
Copy link

@richardgohth Thank you for your reply, did it work well in translating the Yolo txt format to xml? if yes, then this has to be executed in the cmd for each txt file or where?

@richardgohth
Copy link

richardgohth commented Mar 2, 2020

yes for each file
we no longer need to do this
hence this script is not maintained
sorry

@MuhammadAsadJaved
Copy link

MuhammadAsadJaved commented Oct 20, 2020

@nourhanTr @richardgohth
I wrote a python program to convert (yolo) .txt annotations to .xml annotations. You can use if you still need it. You can convert all files in a folder at once.

https://github.com/MuhammadAsadJaved/Important-shells/blob/master/README.md#convert-txt-darknet-annotations-to-xml-voc-annotations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants