Code Monkey home page Code Monkey logo

vod-converter's Introduction

Visual Object Dataset converter

Converts between object dataset formats. Requires Python 3.6.

Example: convert from data in KITTI format to Pascal VOC format:

$ python3.6 vod_converter/main.py --from kitti --from-path datasets/mydata-kitti --to voc --to-path datasets/mydata-voc

See main.py for documentation on how to easily plug in additional data formats; you can define a function that can read in your data into a common format, and it will be then ready to convert to any supported format.

Similarly, you can implement a single function that takes the common format and outputs to the filesystem in your format and you will be ready to convert from e.g VOC to yours.

Currently support conversion from:

to:

That 'train.txt' file for KITTI

When reading in KITTI, the script expects a train.txt file that isn't part of the original dataset. This is simply a file with the name of each datapoint you wish to capture. Here's an example with everything in the training set. You can also create it like so:

$ cd datasets/kitti && ls -1 training/image_2 | cut -d. -f1 > train.txt && cd -
$ head datasets/kitti/train.txt
000000
000001
000002
000003
000004
000005
000006
000007
000008
000009

Python2 support

This project is written using features requiring Python3.6+, but there is a fork that has been updated to work in Python2 if you need it.

vod-converter's People

Contributors

krosaen avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vod-converter's Issues

Input for --from path and --to path

Could you tell me what is the input for --from path and --to path? is it the whole dataset + annotation file? or is it just annotation file?

KITTI annotations written on multiple lines and with visible quote characters

When converting from PASCAL to VOC I end up with KITTI annotation files with the label on one line and the annotation info on the following line, and with quote marks in the file. For example:

"
   handgun
  " 0.0 0 -1 1.0 3.0 607.0 266.0 -1 -1 -1 -1 -1 -1 -1

My understanding based on other KITTI files I've seen is that we should instead have everything on one line like so:

handgun 0.0 0 -1 1.0 3.0 607.0 266.0 -1 -1 -1 -1 -1 -1 -1

I assume that this is happening in kitti.py in the KITTIEgestor.egest function.

Am I the only one to have trouble with this? It seems odd that this issue wouldn't come up for others before now.

Where to find train.txt

Hello,
I tried to run the converter, but it fails due to the lack of train.txt, I didn't find it on KITTiI website.

Image has out of bounds bounding boxes

I am working on Stanford drone dataset. I have converted the dataset to KITTI format using these scripts.
https://github.com/rockkingjy/DataFormat_sdd2kitti After conversion, I tried conversion from kitti format to VOC, but I am constantly getting this error.
`Traceback (most recent call last):
File "vod_converter/main.py", line 92, in
filter_images_without_labels=args.filter_images_without_labels))
File "vod_converter/main.py", line 40, in main
filter_images_without_labels=filter_images_without_labels)
File "/home/pranav/vod_converter/vod_converter/converter.py", line 134, in convert
validate_image_detections(image_detections)
File "/home/pranav/vod_converter/vod_converter/converter.py", line 153, in validate_image_detections
raise ValueError(f"Image {image} has out of bounds bounding box {detection}")
ValueError: Image {'id': '1758', 'path': '/home/pranav/test_training/annotation0/training/image_2/1758.png', 'segmented_path': None, 'width': 1424, 'height': 1088} has out of bounds bounding box {'label': 'Pedestrian', 'left': 231.0, 'right': 282.0, 'top': 1078.0, 'bottom': 1088.0}

`
Can you please guide me through this? Why am I getting this error and how to solve it.

Failed to convert from udacity-crowdai to voc: Expected to find home/ycyer/Udatasets1/labels.csv

When I run code as below,I got :
python3.6 vod_converter/main.py --from udacity-crowdai --from-path home/ycyer/Udatasets1 --to voc --to-path home/ycyer/VOCdevkit/voc
INFO:root:Namespace(filter_images_without_labels=False, from_key='udacity-crowdai', from_path='home/ycyer/Udatasets1', select_only_known_labels=False, to_key='voc', to_path='home/ycyer/VOCdevkit/voc')
Failed to convert from udacity-crowdai to voc: Expected to find home/ycyer/Udatasets1/labels.csv

But I checked the Udatasets1,and found labels.csv is init,can anybody tell me where I was wrong?

TypeError: %d format: a number is required, not str

Hi, I have some troubles trying to run the code for transform from Kitti Dataset format to VOC format with the next log:

$ python vod_converter/main.py --from kitti --from-path /g/data_object_image_2/ --to voc --to-path ./out INFO:root:Namespace(filter_images_without_labels=False, from_key='kitti', from_path='G:/data_object_image_2/', select_only_known_labels=False, to_key='voc', to_path='./out') Traceback (most recent call last): File "vod_converter/main.py", line 92, in <module> filter_images_without_labels=args.filter_images_without_labels)) File "vod_converter/main.py", line 40, in main filter_images_without_labels=filter_images_without_labels) File "C:\Users\ASDF\Desktop\GPUexp\vod-converter\vod_converter\converter.py", line 140, in convert egestor.egest(image_detections=image_detections, root=to_path) File "C:\Users\ASDF\Desktop\GPUexp\vod-converter\vod_converter\voc.py", line 122, in egest shutil.copyfile(image['path'], "%s/%d.%s" % (images_path, image_id, src_extension)) TypeError: %d format: a number is required, not str (py36)

Later if I modify this "%s/%d.%s" % (images_path, image_id, src_extension)) to ------>{}/{}.{}" .format(images_path, image_id,src_extension)` format, the next error message is show:

`
$ python vod_converter/main.py --from kitti --from-path /g/data_object_image_2/ --to voc --to-path ./out
INFO:root:Namespace(filter_images_without_labels=False, from_key='kitti', from_path='G:/data_object_image_2/', select_only_known_labels=False, to_key='voc', to_path='./out')
Traceback (most recent call last):
File "C:\Users\ASDF.conda\envs\py36\lib\xml\etree\ElementTree.py", line 1066, in _escape_cdata
if "&" in text:
TypeError: argument of type 'int' is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "vod_converter/main.py", line 92, in
filter_images_without_labels=args.filter_images_without_labels))
File "vod_converter/main.py", line 40, in main
filter_images_without_labels=filter_images_without_labels)
File "C:\Users\ASDF\Desktop\GPUexp\vod-converter\vod_converter\converter.py", line 140, in convert
egestor.egest(image_detections=image_detections, root=to_path)
File "C:\Users\ASDF\Desktop\GPUexp\vod-converter\vod_converter\voc.py", line 164, in egest
ET.ElementTree(xml_root).write("{}/{}.xml".format(str(annotations_path), str(image_id)))
File "C:\Users\ASDF.conda\envs\py36\lib\xml\etree\ElementTree.py", line 776, in write
short_empty_elements=short_empty_elements)
File "C:\Users\ASDF.conda\envs\py36\lib\xml\etree\ElementTree.py", line 941, in _serialize_xml
short_empty_elements=short_empty_elements)
File "C:\Users\ASDF.conda\envs\py36\lib\xml\etree\ElementTree.py", line 941, in _serialize_xml
short_empty_elements=short_empty_elements)
File "C:\Users\ASDF.conda\envs\py36\lib\xml\etree\ElementTree.py", line 938, in _serialize_xml
write(_escape_cdata(text))
File "C:\Users\ASDF.conda\envs\py36\lib\xml\etree\ElementTree.py", line 1074, in _escape_cdata
_raise_serialization_error(text)
File "C:\Users\ASDF.conda\envs\py36\lib\xml\etree\ElementTree.py", line 1057, in _raise_serialization_error
"cannot serialize %r (type %s)" % (text, type(text).name)
TypeError: cannot serialize 3 (type int)
`

Maybe is the python version? although the same happens in py27 fork version of the code, thanks for the feedback

Converters not working

I would like to convert udacity to voc. I wonder whether the converter I am using is right or not because it keep giving me error

First i tried this main.py

~/Documents/vod-converter$ python3.6 vod_converter/main.py --from udacity --from-path datasets/mydata-udacity/ --to voc --to-path datasets/mydata-voc/

output is

Traceback (most recent call last):
  File "vod_converter/main.py", line 12, in <module>
    import kitti
  File "/home/borinyun/Documents/vod-converter/vod_converter/kitti.py", line 35, in <module>
    from PIL import Image
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "vod_converter/main.py", line 12, in <module>
    import kitti
  File "/home/borinyun/Documents/vod-converter/vod_converter/kitti.py", line 35, in <module>
    from PIL import Image
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging'

Then I tried this udacity.py

~/Documents/vod-converter$ python3.6 vod_converter/udacity.py --from udacity --from-path datasets/mydata-udacity/ --to voc --to-path datasets/mydata-voc/

output

Traceback (most recent call last):
  File "vod_converter/udacity.py", line 10, in <module>
    from PIL import Image
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "vod_converter/udacity.py", line 10, in <module>
    from PIL import Image
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging'

Failed to convert from kitti to voc: Expected subdirectory training/image_2 ?????

Hi
I am trying to convert txt to pascal voc, but I couldn't I tried python2 and puthon3.6, both give same error

(py3.6) abdu@grasp-uoit:~/1vod-converter$ python3.6 vod_converter/main.py --from kitti --from-path /home/abdu/datasets/mydata-kitti --to voc --to-path /home/abdu/datasets/mydata-voc
INFO:root:Namespace(filter_images_without_labels=False, from_key='kitti', from_path='/home/abdu/datasets/mydata-kitti', select_only_known_labels=False, to_key='voc', to_path='/home/abdu/datasets/mydata-voc')
Failed to convert from kitti to voc: Expected subdirectory training/image_2 within /home/abdu/datasets/mydata-kitti

Any suggestions please ???

Remind me that the conversion was successful, but the folder is empty and there is no data

python main.py --from udacity-crowdai --from-path ../datasets/crowdai --to voc --to-path ../datasets/crowdai-voc
INFO:root:Namespace(filter_images_without_labels=False, from_key='udacity-crowdai', from_path='../datasets/crowdai', select_only_known_labels=False, to_key='voc', to_path='../datasets/crowdai-voc')
Successfully converted from udacity-crowdai to voc.

but the folder path "datasets/autti-voc/VOC2012/Annotations" is empty and there is no data

Updates to facilitate registration/upload to PyPI

In order to register and upload this to PyPI there should be a setup.py etc. in order to facilitate the process, as described here.

The short version:

  1. Get the setup.py file in shape as described here
  2. $ rm -rf dist
  3. $ python setup.py sdist bdist_wheel
  4. $ twine check dist/*
  5. $ twine upload --repository-url https://test.pypi.org/legacy/ dist/*
  6. $ twine upload dist/*

If this is useful for the project I can make the updates and submit a PR but I don't think I have permission to upload the package to PyPI.

ValueError: not enough values to unpack (expected 4, got 0)

Traceback (most recent call last):
File "vod_converter/main.py", line 92, in
filter_images_without_labels=args.filter_images_without_labels))
File "vod_converter/main.py", line 40, in main
filter_images_without_labels=filter_images_without_labels)
File "/media/liufan/689097F39097C64A/ubuntu16.04/dataConverter/vod-converter/vod_converter/converter.py", line 133, in convert
image_detections = ingestor.ingest(from_path)
File "/media/liufan/689097F39097C64A/ubuntu16.04/dataConverter/vod-converter/vod_converter/kitti.py", line 60, in ingest
return [self._get_image_detection(path, image_name, image_ext=image_ext) for image_name in image_ids]
File "/media/liufan/689097F39097C64A/ubuntu16.04/dataConverter/vod-converter/vod_converter/kitti.py", line 60, in
return [self._get_image_detection(path, image_name, image_ext=image_ext) for image_name in image_ids]
File "/media/liufan/689097F39097C64A/ubuntu16.04/dataConverter/vod-converter/vod_converter/kitti.py", line 75, in _get_image_detection
detections = self._get_detections(detections_fpath)
File "/media/liufan/689097F39097C64A/ubuntu16.04/dataConverter/vod-converter/vod_converter/kitti.py", line 95, in _get_detections
x1, y1, x2, y2 = map(float, row[4:8])

Inconsistent format in generated data

Content format of train.txt from KITTI consists of 2 things: path to image file and a path to label file of that image. Even though this piece of data may seem redundant, I think it is better to have a consistent format with KITTI.

Fixed in #1

Error while converting from VOC to Kitti format

Hi. I am trying to convert annotation files from pascal VOC to Kitti format. When I run the command,
python3.6 vod_converter/main.py --from voc --from-path ~/Desktop/voc --to kitti --to-path ~/Desktop/kitti
I get the error below:

Failed to convert from voc to kitti: Expected subdirectory ImageSets within /Users/sowmya/Desktop/voc/VOC2012

Could you please let me know where the conversion possibly failed? Also, it would be really helpful to specify the dependencies in ReadMe, such as PIL or jsonschema libraries.

Thank you so much,
Sowmya

Exception(f"at index {i}") from se Exception: at index 0

I am trying to convert this Kitti Road/Lane Detection Evaluation 2013 to Pascal voc like dataset.

I have renamed calib folders (found under training and testing folders) to label_2 and I have created the train.txt like it was instructed. The first lines of train.txt are the following:
um_000000
um_000001
um_000002
um_000003
um_000004
um_000005
um_000006
um_000007

When I convert it I get the following validation error:

INFO:root:Namespace(filter_images_without_labels=False, from_key='kitti', from_path='./Kitti/data_road', select_only_known_labels=False, to_key='voc', to_path='./Kitti-voc')
Traceback (most recent call last):
File "/home/bm-pc/Documents/Thesis/vod-converter-master/vod_converter/converter.py", line 147, in validate_image_detections
validate_schema(image_detection, IMAGE_DETECTION_SCHEMA)
File "/home/bm-pc/Documents/Thesis/vod-converter-master/vod_converter/converter.py", line 22, in validate_schema
return raw_validate(data, schema, types={"array": (list, tuple)})
File "/home/bm-pc/.local/lib/python3.6/site-packages/jsonschema/validators.py", line 541, in validate
cls(schema, *args, **kwargs).validate(instance)
File "/home/bm-pc/.local/lib/python3.6/site-packages/jsonschema/validators.py", line 130, in validate
raise error
jsonschema.exceptions.ValidationError: -387.5744 is less than the minimum of 0

Failed validating 'minimum' in schema['properties']['detections']['items']['properties']['left']:
{'minimum': 0, 'type': 'number'}

On instance['detections'][1]['left']:
-387.5744

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "../vod-converter-master/vod_converter/main.py", line 92, in
filter_images_without_labels=args.filter_images_without_labels))
File "../vod-converter-master/vod_converter/main.py", line 40, in main
filter_images_without_labels=filter_images_without_labels)
File "/home/bm-pc/Documents/Thesis/vod-converter-master/vod_converter/converter.py", line 134, in convert
validate_image_detections(image_detections)
File "/home/bm-pc/Documents/Thesis/vod-converter-master/vod_converter/converter.py", line 149, in validate_image_detections
raise Exception(f"at index {i}") from se
Exception: at index 0

Could you tell me please what did I miss or this converter is intended to be used only with these Kitti datasets:

Thank you.

Why the decrementation of bounding box coordinate values when ingesting PASCAL VOC?

When the VOCIngestor._get_detection function parses bounding box coordinate values it decrements the values. Why is this so?

For example, if my image is 200 pixels wide and contains a box that's full width with xmin==0 and xmax==199 then this code results in a detection with left==-1 and right==198. Is this really what we want? It gives me trouble in this situation, in that it results in invalid boxes since -1 is out-of-range.

Also the box coordinate decrementations result in the box being pushed to the left/top by one pixel in every case. Is this really what we want? Perhaps there was some justification for the decrementations when the code was written that's just not obvious to me?

Failed to conver from udacity to voc:main.py: error: the following arguments are required: --from-path

when I run the code :
python3.6 vod_converter/main.py --from udacity --from-/home/ycyer/Udataset1 --to voc --to-path /home/ycyer/VOCdevkit/VOC2012/JPEGImages2
the output is :
sage: main.py [-h] --from FROM_KEY --from-path FROM_PATH --to TO_KEY
--to-path TO_PATH [--select-only-known-labels]
[--filter-images-without-labels]
main.py: error: the following arguments are required: --from-path

I think I didn't write the paty right,but actually I don't know how to set the voc path, can anyone tell me how to fix this?? Thanks for advance!!!

Only folders generated when converting from udacity to voc

I'm trying to convert from udacity-autti and udacity-crowdai to voc, but only the raw folders are generated without any files inside. Converting from KITTI to voc works like a charm.

I am using this command in Anaconda:

(C:\ProgramData\Anaconda3) D:\data\KITTI_dataset\KITTI_2_VOC_converter_vod-converter-master\vod-converter-master>python vod_converter/main.py --from udacity-crowdai --from-path D:\data\CrowdAI_dataset\object-detection-crowdai\ --to voc --to-path D:\data\CrowdAI_voc\object-detection-crowdai\

Getting this output:

INFO:root:Namespace(filter_images_without_labels=False, from_key='udacity-crowdai', from_path='D:\data\CrowdAI_dataset\object-detection-crowdai\', select_only_known_labels=False, to_key='voc', to_path='D:\data\CrowdAI_voc\object-detection-crowdai\')
Successfully converted from udacity-crowdai to voc.

This folder is generated:
_D:\data\CrowdAI_voc\object-detection-crowdai\VOC2012_
with subfolders:
Annotations
ImageSets\Main
JPEGImages

same for
--from udacity-autti

Images and labels.csv are placed in D:\data\CrowdAI_dataset\object-detection-crowdai

what am I doing wrong or is there a problem with the scripts?

Expected subdirectory ImageSets within data [voc to kitti]

@krosaen I am trying to convert from voc to kitti

home@home-lnx:~/Desktop/vod-converter-master$ python3.6 vod_converter/main.py --from voc --from-path datasets/ --to kitti --to-path dataset
INFO:root:Namespace(filter_images_without_labels=False, from_key='voc', from_path='datasets/', select_only_known_labels=False, to_key='kitti', to_path='dataset')
Failed to convert from voc to kitti: Expected subdirectory ImageSets within datasets//VOC2012

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.