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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
.pytest_cache
dist
build
fastlabel.egg-info
fastlabel.egg-info
test*.py
annotation.json
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all: black isort

black:
black .

isort:
isort .
157 changes: 143 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,159 @@ import fastlabel
client = fastlabel.Client()
```

## Model Analysis
## Limitation

### Upload Predictions
API is allowed to call 5000 times per hour. If you create/delete a large size of tasks, please wait a second for every requests.

## Task

### Create Task

- Create a new task.

```python
import fastlabel
task = client.create_image_task(
project_id="YOUR_PROJECT_ID",
key="sample.jpg",
url="https://sample.com/sample.jpg"
)
```

# Initialize client
client = fastlabel.Client()
- Create a new task with pre-defined labels. (Class should be configured on your project in advance)

```python
task = client.create_image_task(
project_id="YOUR_PROJECT_ID",
key="sample.jpg",
url="https://sample.com/sample.jpg",
labels=[
{
"type": "bbox",
"value": "bbox",
"points": [
{ "x": 100, "y": 100}, # top-left
{ "x": 200, "y": 200} # bottom-right
]
}
]
)
```

# Create predictions
> Check [examples/create_image_task.py](/examples/create_image_task.py) for other label types, such as line, keyPoint and polygon.

### Find Task

- Find a single task.

```python
task = client.find_task(task_id="YOUR_TASK_ID")
```

### Get Tasks

- Get tasks. (Up to 100 tasks)

```python
tasks = client.get_tasks(project_id="YOUR_PROJECT_ID")
```

- Filter and Get tasks. (Up to 100 tasks)

```python
tasks = client.get_tasks(
project_id="YOUR_PROJECT_ID",
status="submitted", # status can be 'registered', 'registered', 'submitted' or 'skipped'
review_status="accepted" # review_status can be 'notReviewed', 'inProgress', 'accepted' or 'declined'
)
```

- Get a large size of tasks. (Over 100 tasks)

```python
import time

# Iterate pages until new tasks are empty.
all_tasks = []
start_after = None
while True:
time.sleep(1)

tasks = client.get_tasks(project_id="YOUR_PROJECT_ID", start_after=start_after)
all_tasks.extend(tasks)

if len(tasks) > 0:
start_after = tasks[-1]["id"] # Set the last task id to start_after
else:
break
```

> Please wait a second before sending another requests!

### Delete Task

```python
client.delete_task(task_id="YOUR_TASK_ID")
```

### Task Response

- Example of a single task object

```python
{
"id": "YOUR_TASK_ID",
"key": "sample.png",
"assigneeId": null,
"assigneeName": null,
"status": "registered",
"reviewAssigneeId": null,
"reviewAssigneeName": null,
"reviewStatus": "notReviewed",
"projectId": "YOUR_PROJECT_ID",
"datasetId": "YOUR_DATASET_ID",
"labels": [
{
"id": "YOUR_LABEL_ID",
"type": "bbox",
"value": "window",
"title": "窓",
"color": "#d9713e",
"metadata": [],
"points": [
{ "x": 100, "y": 100}, # top-left
{ "x": 200, "y": 200} # bottom-right
]
}
],
"duration": 0,
"image": {
"width": 1500,
"height": 1200
},
"createdAt": "2020-12-25T15:02:00.513",
"updatedAt": "2020-12-25T15:02:00.513"
}
```

## Model Analysis

### Upload Predictions

```python
# Create your model predictions
predictions = [
{
"fileKey": "sample1.jpg", # file name exists in your project
"fileKey": "sample.jpg", # file name exists in your project
"labels": [
{
"value": "line_a", # class value exists in your project
"value": "bbox_a", # class value exists in your project
"points": [
{ "x": 10, "y": 10 },
{ "x": 20, "y": 20 },
{ "x": 10, "y": 10 }, # top-left
{ "x": 20, "y": 20 }, # botom-right
]
},
{
"value": "line_b",
"value": "bbox_b",
"points": [
{ "x": 30, "y": 30 },
{ "x": 40, "y": 40 },
Expand All @@ -58,9 +187,9 @@ predictions = [

# Upload predictions
client.upload_predictions(
project_id="project_id", # your fastlabel project id
analysis_type="line", # annotation type to be analyze ("bbox" or "line" are supported)
threshold=25, # IoU percentage/pixel to analyze labels. (Ex: 0 - 100)
project_id="YOUR_PROJECT_ID", # your fastlabel project id
analysis_type="bbox", # annotation type to be analyze (Only "bbox" or "line" are supported)
threshold=80, # IoU percentage/pixel distance to check labels are correct. (Ex: 0 - 100)
predictions=predictions
)
```
Expand Down
22 changes: 22 additions & 0 deletions contributing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Contributing Guideline

## Pull Request Checklist

Before sending your pull requests, make sure you followed this list.

- Read Contributing Guideline
- Run formatter and linter

## Formatter and Linter

### Installation

```bash
$ pip install -r contributing/requirements.txt
```

### Run Formatter and Linter

```bash
make all
```
3 changes: 3 additions & 0 deletions contributing/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
black==20.8b1
flake8==3.8.4
isort==5.6.4
61 changes: 61 additions & 0 deletions examples/create_image_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from pprint import pprint

import fastlabel

# Initialize client
client = fastlabel.Client()

project_id = "YOUR_PROJECT_ID"
key = "YOUR_IMAGE_KEY" # Should be an unique in your project
url = "YOUR_IMAGE_URL"
labels = [
{
"type": "bbox",
"value": "bbox",
"points": [
{"x": 100, "y": 100}, # top-left
{"x": 200, "y": 200}, # bottom-right
],
},
{
"type": "line",
"value": "line",
"points": [{"x": 200, "y": 200}, {"x": 250, "y": 250}],
},
{"type": "keyPoint", "value": "keyPoint", "points": {"x": 10, "y": 10}},
{
"type": "polygon",
"value": "polygon",
"points": [
{"x": 300, "y": 300},
{"x": 320, "y": 320},
{"x": 340, "y": 220},
{"x": 310, "y": 200},
],
},
{
"type": "polyline",
"value": "polyline",
"points": [
{"x": 100, "y": 300},
{"x": 120, "y": 320},
{"x": 140, "y": 220},
{"x": 110, "y": 200},
],
},
{
"type": "segmentation",
"value": "segmentation",
"points": [
[
{"x": 400, "y": 400},
{"x": 420, "y": 420},
{"x": 440, "y": 420},
{"x": 410, "y": 400},
]
],
},
]

task = client.create_image_task(project_id=project_id, key=key, url=url, labels=labels)
pprint(task)
Loading