Comments (1)
Label Studio does not have built-in support for the Labelme JSON format. However, you can convert the Labelme JSON format to the Label Studio JSON format using a custom script. Here's an example of how you can do this:
- First, let's assume you have a Labelme JSON file named
labelme_annotations.json
with the following content:
{
"shapes": [
{
"label": "dog",
"points": [
[100, 100],
[200, 100],
[200, 200],
[100, 200]
]
},
{
"label": "cat",
"points": [
[300, 300],
[400, 300],
[400, 400],
[300, 400]
]
}
],
"imagePath": "example.jpg"
}
- Create a Python script named
convert_labelme_to_labelstudio.py
with the following content:
import json
def convert_labelme_to_labelstudio(labelme_json):
labelstudio_json = {
"image": labelme_json["imagePath"],
"annotations": []
}
for shape in labelme_json["shapes"]:
annotation = {
"id": len(labelstudio_json["annotations"]) + 1,
"type": "rectanglelabels",
"value": {
"x": shape["points"][0][0],
"y": shape["points"][0][1],
"width": shape["points"][1][0] - shape["points"][0][0],
"height": shape["points"][2][1] - shape["points"][1][1],
"rectanglelabels": [shape["label"]]
}
}
labelstudio_json["annotations"].append(annotation)
return labelstudio_json
if __name__ == "__main__":
with open("labelme_annotations.json", "r") as f:
labelme_json = json.load(f)
labelstudio_json = convert_labelme_to_labelstudio(labelme_json)
with open("labelstudio_annotations.json", "w") as f:
json.dump(labelstudio_json, f, indent=2)
- Run the script to convert the Labelme JSON file to the Label Studio JSON format:
python convert_labelme_to_labelstudio.py
- The script will create a new file named
labelstudio_annotations.json
with the following content:
{
"image": "example.jpg",
"annotations": [
{
"id": 1,
"type": "rectanglelabels",
"value": {
"x": 100,
"y": 100,
"width": 100,
"height": 100,
"rectanglelabels": [
"dog"
]
}
},
{
"id": 2,
"type": "rectanglelabels",
"value": {
"x": 300,
"y": 300,
"width": 100,
"height": 100,
"rectanglelabels": [
"cat"
]
}
}
]
}
- Now you can import the
labelstudio_annotations.json
file into Label Studio.
Please note that this example assumes you are working with rectangular bounding boxes. You might need to adjust the script to handle other annotation types supported by Labelme and Label Studio.
from label-studio-converter.
Related Issues (20)
- Python directions in README are wrong HOT 1
- YOLO, COCO export error
- Are there any Plans to support Object Tracking formats?
- Export of OCR task into COCO and YOLO doesn't work HOT 2
- Export to YOLO format for Video Annotation Doesn't work.
- Export columns selection
- What is the correct way to convert bbox from label studio to LayoutLMv3Processor bbox format?
- Oriented Bounding Box HOT 1
- RectangleLabels : x,y values inconsistent HOT 1
- YOLO import to LS doesnt import labels HOT 2
- The iter_from_dir that uses`json.load` in method convert_to_voc does not open the json file.
- bug in "iter_from_json_file" method
- export to yolov8 format HOT 5
- CONLL Conversion drops NER labels from token classification
- How to make YOLO RAW tag output format be converted to pre-annotated
- Unable to convert multi-class instance segmentation dataset from YOLO TXT format HOT 1
- Why can't I use BrushLabel and export it to VOC?
- It can not handle COCO type datasets that don't have segmentation annotations HOT 1
- Trying to import a Pascal VOC dataset type and it does not work HOT 1
- [suggestion] Export format add YOLOV8-OBB
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from label-studio-converter.