Giter Club home page Giter Club logo

coco-annotations-to-xml's People

Contributors

mhiyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

coco-annotations-to-xml's Issues

TypeError: cannot serialize nan (type float64) while tree.write

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!

image_id issue - can't open/read file

@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!

TypeError: list indices must be integer or slices, not str

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.