mhiyer / coco-annotations-to-xml Goto Github PK
View Code? Open in Web Editor NEWConvert COCO annotations to xml format
Convert COCO annotations to xml format
Hello, I am getting an error while writing the xml file: tree.write(anno_path)
Entire log:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 1067, in _escape_cdata
if "&" in text:
TypeError: argument of type 'numpy.float64' is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 799, in _get_writer
yield file.write
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 777, in write
short_empty_elements=short_empty_elements)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 942, in _serialize_xml
short_empty_elements=short_empty_elements)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 942, in _serialize_xml
short_empty_elements=short_empty_elements)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 939, in _serialize_xml
write(_escape_cdata(text))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 1075, in _escape_cdata
_raise_serialization_error(text)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 1058, in _raise_serialization_error
"cannot serialize %r (type %s)" % (text, type(text).__name__)
TypeError: cannot serialize nan (type float64)
How can I resolve this? Thanks in advance!
@mhiyer Hello. I have a dataset annotated with coco json format, but I need to convert it to xml PascalVOC format. I tried to use your script to convert json to xml annotations, but I am getting the following error.
[ WARN:[email protected]] global loadsave.cpp:244 cv::findDecoder imread_('C:/User/dataset/subset-1/000000009526.jpg'): can't open/read file: check file path/integrity
Traceback (most recent call last):
File "coco_get_annotations_xml_format.py", line 130, in
write_to_xml(image_name, image_dict, image_folder, savepath)
File "coco_get_annotations_xml_format.py", line 33, in write_to_xml
h,w,d = img.shape
AttributeError: 'NoneType' object has no attribute 'shape'
Then I noticed that in coco dataset the name of images are like numerical 000000009526.jpg and I understood that '{0:012d}.jpg'.format(image_id) part was written for particularly for coco dataset.
My image's names are 362356,7729.jpg or 15645644.565.jpg. How I should modify the script so it just makes a match with image_id.jpg image in json file annotations and convert/save it as image_id.xml ? Look forward to hearing from you!
Traceback (most recent call last):
File "annotations_to_xml.py", line 103, in
annotations = doc['annotations']
TypeError: list indices must be integers or slices, not str
I am facing this problem while converting coco annotations to xml format
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.