Import labelstudio segmentation from a different machine

For an image segmentation task, how can a user export both images and performed annotations (done in LS) and pass them to me? I guess exporting them as COCO should work, as the resulting zip file has both images and a JSON with annotations, but how do I import it on my machine?

Why do you need COCO for this? I would highly recommend to use native LS JSON format.

Thanks for your reply. I also have the LS JSON, and the data are imported from local storage. How do I import the annotations from LS JSON?

Just re-connect local storage with images and then import Label Studio JSON file using Data Manager => Import.

If I got it correctly, “Data Manager => Import” means: from project’s settings page “Import” then upload JSON file. Here I get a validation error starting w/

Error at item 0: “undefined$” key is expected in task data [assume: item[“data”] = task root with values] :: {‘id’: 1202, ‘annotations’: [{‘id’: 757, ‘completed_by’: 1, ‘result’: [{‘original_width’: 3024, ‘original_height’: 4032, ‘image_rotation’: 0, ‘value’: {‘points’: [[41.177519616523426, 44.816646570584304], [40.53802169684623, 45.21633277038256], [40.697896176765525, 45.49611311024133], [40.43143871023336, 46.09564240993871], [40.53802169684623,

Or should I do smth else?

What labeling config do you have?

Could you show the full error message?

Semantic segmentations with polygons; the labels are loaded manually (although I expect to be fetched from json).

I need to see the labeling config code here

the code for config:

<View>

  <Header value="Select label and click the image to start"/>
  <Image name="image" value="$image" zoom="true"/>

  <PolygonLabels name="label" toName="image" strokeWidth="3" pointSize="small" opacity="0.9">
    
    
  <Label value="Background" background="#FFA39E"/><Label value="Trees without damages" background="#D4380D"/><Label value="DA&lt;25" background="#FFC069"/><Label value="DA100" background="#AD8B00"/><Label value="DA200" background="#D3F261"/><Label value="DA&gt;200" background="#389E0D"/><Label value="DC&lt;25" background="#5CDBD3"/><Label value="DC100" background="#096DD9"/><Label value="DC200" background="#ADC6FF"/><Label value="DC&gt;200" background="#9254DE"/><Label value="DZ&lt;25" background="#F759AB"/><Label value="DZ100" background="#FFA39E"/><Label value="DZ200" background="#D4380D"/><Label value="DZ&gt;200" background="#FFC069"/></PolygonLabels>

</View>

Where did you get this json file?

Can also share a snippet of the json that you’re trying to import?

[{"id":1202,"annotations":[{"id":757,"completed_by":1,"result":[{"original_width":3024,"original_height":4032,"image_rotation":0,"value":{"points":[[41.177519616523426,44.816646570584304],[40.53802169684623,45.21633277038256],[40.697896176765525,45.49611311024133],[40.43143871023336,46.09564240993871],[40.53802169684623,46.615234469676444],[40.32485572362049,47.174795149393994],[40.218272737007624,48.21397926886945],[40.271564230314056,48.853477188546655],[40.271564230314056,49.53294372820368],[40.05839825708832,50.29234750782037],[39.845232283862586,51.091719907416866],[39.57877481733042,51.81115506705372],[39.73023738860619,52.11248391721032],[39.58641414521037,52.40526694840896],[39.58641414521037,52.71345961282857],[39.36272639543492,52.87926216039954],[39.29492400926261,53.25217528434728],[39.340125600044146,53.62508840829502],[39.453129576998,53.94714974261351],[39.56613355395186,54.37091465619047],[39.43052878160724,54.574321814707424],[39.36272639543492,54.79467956976746],[39.219459083091586,55.775173409839375],[39.166167589785154,56.694451669375354],[39.43262505631731,57.73363578885081],[39.219459083091586,58.53300818844732],[39.48591654962375,59.37234920802366],[39.64579102954306,60.371564707519276],[39.69908252284949,61.33081158703509],[39.69908252284949,62.36999570651054],[39.69908252284949,63.369211206006185],[39.91224849607523,64.24852084556233],[40.445163429139555,64.72814428532024],[41.40441030865537,64.56826980540093],[42.25707420155831,64.16858360560268],[42.789989134622644,63.32924258602636],[43.21632108107411,62.4499329464702],[43.58936153421915,61.250874347075445],[44.01569348067061,60.29162746755963],[44.601899907041386,58.93269438824558],[45.028231853492855,57.8535416487903],[45.561146786557195,56.65448304939553],[45.77431275978292,55.57533030994025],[46.0407702263151,54.73598929036392],[46.27278520343011,53.51689885449391],[46.14381978962855,52.74310637168449],[46.01485437582697,51.67914170782154],[45.950371668926195,50.32500486290507],[46.46623332413247,49.40612628956888],[46.917612272437964,48.342161625705934],[46.853129565537174,47.326558992018576],[46.595198737934034,46.601128539384746],[47.24002580694188,46.504404479033575],[47.5624393414458,45.4888018453462],[47.75588746214815,44.61828530218562],[47.52892015353361,44.71834173170567],[47.43630026941051,45.03093384062113],[47.220187206456615,45.0656662971673],[46.84970766996421,45.100398753713456],[46.602721312302606,45.1582861812904],[46.20136848110252,45.29721600747505],[45.753705707840865,45.227751094382725],[45.429536113410016,45.21617360886733],[45.012746634856065,45.21617360886733],[44.827506866609866,45.21617360886733],[44.65770374571751,45.0656662971673],[44.56508386159441,44.89200401443648],[44.44159068276362,44.70676424619028],[44.287224209225116,44.5099469924287],[44.04023785156352,44.35943968072866],[43.42716043979609,43.9248220170447],[43.03008254541654,44.0489088590383],[42.73227412463188,43.999274122240855],[42.500645352910475,44.14817833263319],[42.16974710759419,44.14817833263319],[41.905028511341165,43.90000464864597],[41.73957938868301,44.14817833263319],[41.507950616961615,44.29708254302551],[41.34250149430347,44.42116938501913]],"closed":true,

We need just a part with “data” dictionary. Where did you get this json?

It’s from a coworker.

Thanks for the snippet @lmsasu, I think the reason the import is failing is because your labelling config expects an image object and your json import does not contain any image path, which leads to an undefined error.

Your json be in this type of format:

   [
     {
       "data": {
         "image": "path/to/your/image.jpg"
       },
       "annotations": [
         {
           "id": 757,
           "completed_by": 1,
           "result": [
             {
               "original_width": 3024,
               "original_height": 4032,
               "image_rotation": 0,
               "value": {
                 "points": [
                   [41.177519616523426, 44.816646570584304],
                   [40.53802169684623, 45.21633277038256],
                   [40.697896176765525, 45.49611311024133],
                   [40.43143871023336, 46.09564240993871],
                   [40.53802169684623, 46.21633277038256]
                 ],
                 "polygonlabels": ["Background"]
               },
               "from_name": "label",
               "to_name": "image",
               "type": "polygonlabels"
             }
           ]
         }
       ]
     }
   ]
1 Like

He needs normally export json from the data manager page => Export => JSON.

1 Like

You can view this doc to see how to export in Label Studio: Label Studio Documentation — Export Annotations

Data Manager for the Community Edition of Label Studio just refers to the default view of the project.

you mean: project page → export → “export data” popup → json? not sure what “data manager page” means

This is how the JSON file I got was produced.
To summarize:

  1. I define a new project
  2. In its settings page I define “source cloud storage” as “Local files” and import the images into it. “Treat every bucket object as a source file” must be selected, otherwise I get an error.
  3. I define in “Labeling interface” the template, e.g. “semantic segmentation with polygons”. I manually add here the labels used for segmentation.
  4. In project’s page click “import” and upload the LS JSON file.

If I do like this, then the images are loaded twice, but: in the first images i see as pictures (but no annotation), and after importing LS JSON i see the same files, with 1 annotation task per file, but the image itself is not linked to the entry:

How could I get both the images and their annotations from JSON?