Package: koistudio-converter
KoiStudio ConverterTable of ContentsIntroductionExamplesJSONCSVCoNLL 2003COCOPascal VOC XMLContributingLicenseIntroductionLabel Studio Format Converter helps you to encode labels into the format of your favorite machine learning library.ExamplesJSONRunning from the command line:pipinstall-Ulabel-studio-converter
pythonlabel-studio-converterexport-iexported_tasks.json-cexamples/sentiment_analysis/config.xml-ooutput_dir-fCSVRunning from python:fromlabel_studio_converterimportConverterc=Converter('examples/sentiment_analysis/config.xml')c.convert_to_json('examples/sentiment_analysis/completions/','tmp/output.json')Getting output file:tmp/output.json[{"reviewText":"Good case, Excellent value.","sentiment":"Positive"},{"reviewText":"What a waste of money and time!","sentiment":"Negative"},{"reviewText":"The goose neck needs a little coaxing","sentiment":"Neutral"}]Use cases: any tasksCSVRunning from the command line:pythonlabel_studio_converter/cli.py--inputexamples/sentiment_analysis/completions/--configexamples/sentiment_analysis/config.xml--outputoutput_dir--formatCSV--csv-separator$'\t'Running from python:fromlabel_studio_converterimportConverterc=Converter('examples/sentiment_analysis/config.xml')c.convert_to_csv('examples/sentiment_analysis/completions/','output_dir',sep='\t',header=True)Getting output filetmp/output.tsv:reviewText	sentiment
Good case, Excellent value.	Positive
What a waste of money and time!	Negative
The goose neck needs a little coaxing	NeutralUse cases: any tasksCoNLL 2003Running from the command line:pythonlabel_studio_converter/cli.py--inputexamples/named_entity/completions/--configexamples/named_entity/config.xml--outputtmp/output.conll--formatCONLL2003Running from python:fromlabel_studio_converterimportConverterc=Converter('examples/named_entity/config.xml')c.convert_to_conll2003('examples/named_entity/completions/','tmp/output.conll')Getting output filetmp/output.conll-DOCSTART- -X- O
Showers -X- _ O
continued -X- _ O
throughout -X- _ O
the -X- _ O
week -X- _ O
in -X- _ O
the -X- _ O
Bahia -X- _ B-Location
cocoa -X- _ O
zone, -X- _ O
...Use cases: text taggingCOCORunning from the command line:pythonlabel_studio_converter/cli.py--inputexamples/image_bbox/completions/--configexamples/image_bbox/config.xml--outputtmp/output.json--formatCOCO--image-dirtmp/imagesRunning from python:fromlabel_studio_converterimportConverterc=Converter('examples/image_bbox/config.xml')c.convert_to_coco('examples/image_bbox/completions/','tmp/output.conll',output_image_dir='tmp/images')Output images could be found intmp/imagesGetting output filetmp/output.json{"images":[{"width":800,"height":501,"id":0,"file_name":"tmp/images/62a623a0d3cef27a51d3689865e7b08a"}],"categories":[{"id":0,"name":"Planet"},{"id":1,"name":"Moonwalker"}],"annotations":[{"id":0,"image_id":0,"category_id":0,"segmentation":[],"bbox":[299,6,377,260],"ignore":0,"iscrowd":0,"area":98020},{"id":1,"image_id":0,"category_id":1,"segmentation":[],"bbox":[288,300,132,90],"ignore":0,"iscrowd":0,"area":11880}],"info":{"year":2019,"version":"1.0","contributor":"Label Studio"}}Use cases: image object detectionPascal VOC XMLRunning from the command line:pythonlabel_studio_converter/cli.py--inputexamples/image_bbox/completions/--configexamples/image_bbox/config.xml--outputtmp/voc-annotations--formatVOC--image-dirtmp/imagesRunning from python:fromlabel_studio_converterimportConverterc=Converter('examples/image_bbox/config.xml')c.convert_to_voc('examples/image_bbox/completions/','tmp/output.conll',output_image_dir='tmp/images')Output images can be found intmp/imagesCorresponding annotations could be found intmp/voc-annotations/*.xml:<?xml version="1.0" encoding="utf-8"?><annotation><folder>tmp/images</folder><filename>62a623a0d3cef27a51d3689865e7b08a</filename><source><database>MyDatabase</database><annotation>COCO2017</annotation><image>flickr</image><flickrid>NULL</flickrid></source><owner><flickrid>NULL</flickrid><name>LabelStudio</name></owner><size><width>800</width><height>501</height><depth>3</depth></size><segmented>0</segmented><object><name>Planet</name><pose>Unspecified</pose><truncated>0</truncated><difficult>0</difficult><bndbox><xmin>299</xmin><ymin>6</ymin><xmax>676</xmax><ymax>266</ymax></bndbox></object><object><name>Moonwalker</name><pose>Unspecified</pose><truncated>0</truncated><difficult>0</difficult><bndbox><xmin>288</xmin><ymin>300</ymin><xmax>420</xmax><ymax>390</ymax></bndbox></object></annotation>Use cases: image object detectionYOLO to Label Studio converterUsage:label-studio-converter import yolo -i /yolo/root/directory -o ls-tasks.jsonHelp:label-studio-converter import yolo -h

usage: label-studio-converter import yolo [-h] -i INPUT [-o OUTPUT]
                                          [--to-name TO_NAME]
                                          [--from-name FROM_NAME]
                                          [--out-type OUT_TYPE]
                                          [--image-root-url IMAGE_ROOT_URL]
                                          [--image-ext IMAGE_EXT]

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        directory with YOLO where images, labels, notes.json
                        are located
  -o OUTPUT, --output OUTPUT
                        output file with Label Studio JSON tasks
  --to-name TO_NAME     object name from Label Studio labeling config
  --from-name FROM_NAME
                        control tag name from Label Studio labeling config
  --out-type OUT_TYPE   annotation type - "annotations" or "predictions"
  --image-root-url IMAGE_ROOT_URL
                        root URL path where images will be hosted, e.g.:
                        http://example.com/images or s3://my-bucket
  --image-ext IMAGE_EXT
                        image extension to search: .jpg, .pngYOLO export folder example:yolo-folder
  images
   - 1.jpg
   - 2.jpg
   - ...
  labels
   - 1.txt
   - 2.txt

  classes.txtclasses.txt exampleAirplane
CarContributingWe would love to get your help for creating converters to other models. Please feel free to create pull requests.Contributing GuidelineCode Of ConductLicenseThis software is licensed under theApache 2.0 LICENSE©Heartex. 2020