datumaro icon indicating copy to clipboard operation
datumaro copied to clipboard

Support bboxes in Cityscapes

Open MohsinMohammad opened this issue 3 years ago • 4 comments

In the dataset(Cityscapes1) folder, I have placed below folders

  • imgsFine
    • leftImg8bit
      • train
        • - *_leftImg8bit.png
  • gtFine
  • gtBboxCityPersons
  • gtBbox3d
  • gtCoarse

and then executed below commands $ datum create $ datum import -f cityscapes -i D:\Downloads\Compressed\Cityscapes1 --overwrite $ datum export -f voc -o city_out --overwrite

But the generated VOC XML files do not contain object tag.

MohsinMohammad avatar Oct 01 '21 04:10 MohsinMohammad

xml_content

MohsinMohammad avatar Oct 01 '21 05:10 MohsinMohammad

Hi, Currently, our Cityscapes format implementation only works with segmentation masks. We're open for requests and PRs on boxes and cuboids.

As a workaround, you can try to convert masks into boxes using the shapes_to_boxes transform:

datum create <...>
datum import <...>
datum transform -t shapes_to_boxes -o boxes_proj
datum export -p boxes_proj -f voc -o city_out -- --save-images

zhiltsov-max avatar Oct 01 '21 08:10 zhiltsov-max

Thanks @zhiltsov-max . With your solution, able to get the bbox info in XML file. In the generated XML file, all labels are included. However, I need only few labels ( person, car, truck).

I have tried below commands

datum create <...>
datum import <...>
datum transform -t shapes_to_boxes -o boxes_proj
datum transform -p boxes_proj -t remap_labels -o proj_new -- -l person:person -l car:car -l truck:truck -l bus:bus --default delete
datum export -p proj_new -f voc -o cityscapes -- --save-images

When export command is run, below warning is shown. WARNING: The following labels are remapped to background: car, truck, bus

Then in the XML file, only person label is present. Can you let me know how I can retain the required few labels info in the XML

MohsinMohammad avatar Oct 05 '21 11:10 MohsinMohammad

@MohsinMohammad, apparently, you've met the issue being fixed in #478. In the version you're using, try to call export with the -- --label-map cityscapes parameter (if the labels are from Cityscapes) or create a colormap file like this (for custom labels):

labels.txt

# B G R label_name
0 0 0 background
1 2 1 person
4 5 6 car
7 8 9 truck
5 12 6 bus
...

And pass it as -- --label-map labels.txt.

zhiltsov-max avatar Oct 05 '21 12:10 zhiltsov-max