HumanSignal / label-studio-converter

Tools for converting Label Studio annotations into common dataset formats
https://labelstud.io/
255 stars 132 forks source link

Pascal VOC exports empty annotations for polygon selections #168

Open xumix opened 1 year ago

xumix commented 1 year ago

label-studio-converter==0.0.48.dev0 Exported polygon annotation:

<?xml version="1.0" encoding="utf-8"?>
<annotation>
<folder>images</folder>
<filename>C-20-S-CP_jpg.rf.50ca3100575bd7638857fe45f734b730.jpg</filename>
<source>
<database>MyDatabase</database>
<annotation>COCO2017</annotation>
<image>flickr</image>
<flickrid>NULL</flickrid>
<annotator>1</annotator>
</source>
<owner>
<flickrid>NULL</flickrid>
<name>Label Studio</name>
</owner>
<size>
<width>640</width>
<height>640</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
</annotation>

Source task:

{
  "id": 3810,
  "data": {
    "image": "/data/local-files/?d=Ml%5Ccoco-segments%5Ctrain%5CC-20-S-CP_jpg.rf.50ca3100575bd7638857fe45f734b730.jpg"
  },
  "annotations": [
    {
      "id": 819,
      "created_username": " xxx@gmail.com, 1",
      "created_ago": "50 minutes",
      "completed_by": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "avatar": null,
        "email": "xxx@gmail.com",
        "initials": "v."
      },
      "result": [
        {
          "original_width": 640,
          "original_height": 640,
          "image_rotation": 0,
          "value": {
            "polygonlabels": [
              "column"
            ],
            "points": [
              [
                58.60634777376654,
                16.429565282791817
              ],
              [
                61.33263180655835,
                16.429565282791817
              ],
              [
                61.33263180655835,
                76.33859375
              ],
              [
                58.60634777376654,
                76.33859375
              ]
            ]
          },
          "id": "10480af54b",
          "from_name": "label_polys",
          "to_name": "image",
          "type": "polygonlabels",
          "origin": "manual"
        },
        {
          "original_width": 640,
          "original_height": 640,
          "image_rotation": 0,
          "value": {
            "polygonlabels": [
              "column"
            ],
            "points": [
              [
                41.94682611311673,
                22.031250000000004
              ],
              [
                43.81093750000001,
                22.031250000000004
              ],
              [
                43.81093750000001,
                62.83218749999999
              ],
              [
                41.94682611311673,
                62.83218749999999
              ]
            ]
          },
          "id": "4ad89f74f8",
          "from_name": "label_polys",
          "to_name": "image",
          "type": "polygonlabels",
          "origin": "manual"
        },
        {
          "original_width": 640,
          "original_height": 640,
          "image_rotation": 0,
          "value": {
            "polygonlabels": [
              "column"
            ],
            "points": [
              [
                12.940914619202312,
                25.759228921786466
              ],
              [
                16.1079294650327,
                25.759228921786466
              ],
              [
                16.1079294650327,
                66.70912663194733
              ],
              [
                12.940914619202312,
                66.70912663194733
              ]
            ]
          },
          "id": "dff48b1cd7",
          "from_name": "label_polys",
          "to_name": "image",
          "type": "polygonlabels",
          "origin": "manual"
        },
        {
          "original_width": 640,
          "original_height": 640,
          "image_rotation": 0,
          "value": {
            "points": [
              [
                0,
                25.391095066185322
              ],
              [
                12.996389891696749,
                25.75210589651023
              ],
              [
                14.320096269554753,
                66.54632972322503
              ],
              [
                0.12033694344163658,
                68.47172081829122
              ]
            ],
            "polygonlabels": [
              "section"
            ]
          },
          "id": "oZtFHyFuVH",
          "from_name": "label_polys",
          "to_name": "image",
          "type": "polygonlabels",
          "origin": "manual"
        },
        {
          "original_width": 640,
          "original_height": 640,
          "image_rotation": 0,
          "value": {
            "points": [
              [
                15.042117930204576,
                25.992779783393498
              ],
              [
                42.1179302045728,
                27.196149217809868
              ],
              [
                41.997593261131165,
                62.69554753309266
              ],
              [
                15.884476534296029,
                66.30565583634176
              ]
            ],
            "polygonlabels": [
              "section"
            ]
          },
          "id": "Y6D84Gcg6Y",
          "from_name": "label_polys",
          "to_name": "image",
          "type": "polygonlabels",
          "origin": "manual"
        },
        {
          "original_width": 640,
          "original_height": 640,
          "image_rotation": 0,
          "value": {
            "points": [
              [
                43.20096269554753,
                26.955475330926596
              ],
              [
                58.48375451263538,
                24.067388688327316
              ],
              [
                58.724428399518644,
                74.96991576413961
              ],
              [
                43.32129963898917,
                63.17689530685919
              ]
            ],
            "polygonlabels": [
              "section"
            ]
          },
          "id": "LuV3pzY3jq",
          "from_name": "label_polys",
          "to_name": "image",
          "type": "polygonlabels",
          "origin": "manual"
        },
        {
          "original_width": 640,
          "original_height": 640,
          "image_rotation": 0,
          "value": {
            "points": [
              [
                99.87966305655836,
                15.042117930204576
              ],
              [
                60.288808664259925,
                23.586040914560776
              ],
              [
                59.687123947051745,
                76.53429602888085
              ],
              [
                88.4476534296029,
                100
              ],
              [
                99.87966305655836,
                99.87966305655836
              ]
            ],
            "polygonlabels": [
              "section"
            ]
          },
          "id": "s0mj3Wr4RH",
          "from_name": "label_polys",
          "to_name": "image",
          "type": "polygonlabels",
          "origin": "manual"
        },
        {
          "original_width": 640,
          "original_height": 640,
          "image_rotation": 0,
          "value": {
            "points": [
              [
                0,
                25.150421179302047
              ],
              [
                41.997593261131165,
                27.196149217809868
              ],
              [
                41.395908543922985,
                22.262334536702774
              ],
              [
                43.922984356197354,
                21.90132370637786
              ],
              [
                43.561973525872446,
                26.594464500601685
              ],
              [
                58.00240673886882,
                23.94705174488568
              ],
              [
                57.8820697954272,
                17.328519855595662
              ],
              [
                61.97352587244282,
                16.00481347773766
              ],
              [
                61.13116726835138,
                23.104693140794225
              ],
              [
                99.63898916967509,
                14.921780986762936
              ],
              [
                99.87966305655836,
                99.75932611311673
              ],
              [
                88.92900120336944,
                99.63898916967509
              ],
              [
                42.83995186522262,
                63.29723225030082
              ],
              [
                0.12033694344163658,
                68.35138387484956
              ]
            ],
            "polygonlabels": [
              "fence"
            ]
          },
          "id": "lGtMyBhUOl",
          "from_name": "label_polys",
          "to_name": "image",
          "type": "polygonlabels",
          "origin": "manual"
        }
      ],
      "was_cancelled": false,
      "ground_truth": false,
      "created_at": "2022-12-02T13:16:36.900925Z",
      "updated_at": "2022-12-02T13:16:36.900925Z",
      "lead_time": 120.251,
      "task": 3810,
      "parent_prediction": null,
      "parent_annotation": null
    }
  ],
  "predictions": []
}

Labeling interface

<View>
    <View style="display:flex;align-items:start;gap:8px;flex-direction:column-reverse">
      <Header value="Квадраты"/>
        <RectangleLabels name="label_rectangles" toName="image" showInline="true">
            <Label value="column" background="rgba(0, 255, 0, 1)"/>
            <Label value="section" background="#9eb1ff"/>
            <Label value="door" background="#c6d30d"/>
            <Label value="broken-section" background="#ff6bab"/>
            <Label value="broken-column" background="#7600ad"/>
            <Label value="fence" background="#8bc8ce"/>
            <Label value="broken-fence" background="#D4380D"/>
        </RectangleLabels>
    </View>

    <PolygonLabels name="label_polys" toName="image" showInline="true">
        <Label value="column" background="rgba(0, 255, 0, 1)"/>
        <Label value="section" background="#9eb1ff"/>
        <Label value="door" background="#c6d30d"/>
        <Label value="broken-section" background="#ff6bab"/>
        <Label value="broken-column" background="#7600ad"/>
        <Label value="fence" background="#8bc8ce"/>
        <Label value="broken-fence" background="#D4380D"/>
    </PolygonLabels>
    <Image name="image" value="$image" zoom="true" zoomControl="true" rotateControl="true"/>
</View>
KonstantinKorotaev commented 1 year ago

Hi @xumix Pascal VOC data format assumes to have bounding box for annotation. Do you expect that polygons will be transformed to bounding box?

xumix commented 1 year ago

Hi! @KonstantinKorotaev I think that behavior would be preferred to nothing, at least VOTT does it this way