Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 154 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Supported following project types:
- Image - Keypoint
- Image - Line
- Image - Segmentation
- Image - Pose Estimation(not support Create Task)
- Image - All

#### Create Task
Expand Down Expand Up @@ -198,6 +199,76 @@ Example of a single image task object
}
```

Example when the project type is Image - Pose Estimation

```python
{
"id": "YOUR_TASK_ID",
"name": "person.jpg",
"width": 255, # image width
"height": 255, # image height
"url": "YOUR_TASK_URL",
"status": "registered",
"externalStatus": "registered",
"tags": [],
"assignee": "ASSIGNEE_NAME",
"reviewer": "REVIEWER_NAME",
"externalAssignee": "EXTERNAL_ASSIGNEE_NAME",
"externalReviewer": "EXTERNAL_REVIEWER_NAME",
"annotations":[
{
"type":"pose_estimation",
"title":"jesture",
"value":"jesture",
"color":"#10c414",
"attributes": [],
"keypoints":[
{
"name":"頭",
"key":"head",
"value":[
102.59, # x
23.04, # y
1 # 0:invisible, 1:visible
],
"edges":[
"right_shoulder",
"left_shoulder"
]
},
{
"name":"右肩",
"key":"right_shoulder",
"value":[
186.69,
114.11,
1
],
"edges":[
"head"
]
},
{
"name":"左肩",
"key":"left_shoulder",
"value":[
37.23,
109.29,
1
],
"edges":[
"head"
]
}
]
}
],
"createdAt": "2021-02-22T11:25:27.158Z",
"updatedAt": "2021-02-22T11:25:27.158Z"
}
```


### Image Classification

Supported following project types:
Expand Down Expand Up @@ -744,6 +815,55 @@ Example of an annotation object
}
```

Example when the annotation type is Pose Estimation
```python
{
"id":"b12c81c3-ddec-4f98-b41b-cef7f77d26a4",
"type":"pose_estimation",
"title":"jesture",
"value":"jesture",
"color":"#10c414",
"order":1,
"attributes": [],
"keypoints":[
{
"id":"b03ea998-a2f1-4733-b7e9-78cdf73bd38a",
"name":"頭",
"key":"head",
"color":"#0033CC",
"edges":[
"195f5852-c516-498b-b392-24513ce3ea67",
"06b5c968-1786-4d75-a719-951e915e5557"
],
"value": []
},
{
"id":"195f5852-c516-498b-b392-24513ce3ea67",
"name":"右肩",
"key":"right_shoulder",
"color":"#0033CC",
"edges":[
"b03ea998-a2f1-4733-b7e9-78cdf73bd38a"
],
"value": []
},
{
"id":"06b5c968-1786-4d75-a719-951e915e5557",
"name":"左肩",
"key":"left_shoulder",
"color":"#0033CC",
"edges":[
"b03ea998-a2f1-4733-b7e9-78cdf73bd38a"
],
"value": []
}
],
"createdAt":"2021-11-21T09:59:46.714Z",
"updatedAt":"2021-11-21T09:59:46.714Z"
}
```


### Update Annotation

Update an annotation.
Expand Down Expand Up @@ -869,10 +989,14 @@ client.delete_project(project_id="YOUR_PROJECT_ID")

## Converter

Supporting bbox or polygon annotation type.

### COCO

Support the following annotation types.

- bbox
- polygon
- pose estimation

Get tasks and export as a [COCO format](https://cocodataset.org/#format-data) file.

```python
Expand All @@ -886,8 +1010,22 @@ Export with specifying output directory.
client.export_coco(tasks=tasks, output_dir="YOUR_DIRECTROY")
```

If you would like to export pose estimation type annotations, please pass annotations.

```python
project_slug = "YOUR_PROJECT_SLUG"
tasks = client.get_image_tasks(project=project_slug)
annotations = client.get_annotations(project=project_slug)
client.export_coco(tasks=tasks, annotations=annotations, output_dir="YOUR_DIRECTROY")
```

### YOLO

Support the following annotation types.

- bbox
- polygon

Get tasks and export as YOLO format files.

```python
Expand All @@ -908,6 +1046,11 @@ client.export_yolo(tasks=tasks, classes=classes, output_dir="YOUR_DIRECTROY")

### Pascal VOC

Support the following annotation types.

- bbox
- polygon

Get tasks and export as Pascal VOC format files.

```python
Expand All @@ -917,6 +1060,14 @@ client.export_pascalvoc(tasks)

### labelme

Support the following annotation types.

- bbox
- polygon
- points
- line


Get tasks and export as labelme format files.

```python
Expand Down Expand Up @@ -1185,7 +1336,7 @@ for image_file_path in glob.iglob(os.path.join(input_dataset_path, "**/**.jpg"),

### labelme

support the following annotation types.
Support the following annotation types.

- bbox
- polygon
Expand Down
6 changes: 4 additions & 2 deletions fastlabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,14 +1021,16 @@ def __get_yolo_format_annotations(self, dataset_folder_path: str) -> dict:

# Task Convert

def export_coco(self, tasks: list, output_dir: str = os.path.join("output", "coco")) -> None:
def export_coco(self, tasks: list, annotations: list = [], output_dir: str = os.path.join("output", "coco")) -> None:
"""
Convert tasks to COCO format and export as a file.
If you pass annotations, you can export Pose Estimation type annotations.

tasks is a list of tasks. (Required)
annotations is a list of annotations. (Optional)
output_dir is output directory(default: output/coco). (Optional)
"""
coco = converters.to_coco(tasks)
coco = converters.to_coco(tasks, annotations)
os.makedirs(output_dir, exist_ok=True)
file_path = os.path.join(output_dir, "annotations.json")
with open(file_path, 'w') as f:
Expand Down
3 changes: 2 additions & 1 deletion fastlabel/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ class AnnotationType(Enum):
keypoint = "keypoint"
line = "line"
segmentation = "segmentation"
classification = "classification"
classification = "classification"
pose_estimation = "pose_estimation"
Loading