Skip to content

Commit

Permalink
feat(ML-424): update doc with the label command
Browse files Browse the repository at this point in the history
  • Loading branch information
theodu authored and PierreLeveau committed Jun 29, 2022
1 parent 6d8427c commit 77be1ec
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 8 deletions.
158 changes: 158 additions & 0 deletions docs/cli/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Getting started with Kili CLI

## What is Kili CLI

Kili CLI has been designed to run key actions on your projects with powerful commands.
For the actions it supports, the CLI offers a more compact way to manage your projects than the Python SDK. Note that the Python SDK offers more options and may still be used for more complex project management tasks.

## Authentication

- Create and copy a [Kili API key](https://docs.kili-technology.com/docs/creating-an-api-key)
- Add the `KILI_API_KEY` variable in your bash environment (or in the settings of your favorite IDE) by pasting the API key value that you copied earlier:

```bash
export KILI_API_KEY='<you api key value here>'
```

!!! info
While launching commands, you can also provide you API key through the `--api-key` option. If you set your api key in the `KILI_API_KEY` environment variable and provide it once again through the `--api-key` option, Kili CLI will use the api key value provided in command options.

## Usage

The main command is `kili`. It currently has only one subcommand `project` that entails all the commands for project management :

```
kili project [COMMAND]
```
## Workflow example
Let's take an example where you want to start a project from scratch:
### Create a project
To create an IMAGE project:
```
kili project create \\
--interface path/to/interface.json \\
--input-type IMAGE \\
--title "Defect detection" \\
--description "Bottle defects on production line"
```
Ouputs:
```
Project successfully created. Id: cl4ljd3awc5gj0lpbb89nbcqg
```
### List your projects
```
kili project list --max 10
```
Ouputs:
```
title id progress description
---------------------------------------- ------------------------- ---------- -------------------------------
Defect detection cl4ljd3awc5gj0lpbb89nbcqg 0.0% Bottle defects on production...
invoice NER cl3d43bzb0rl71mx4580mpbt1 92.5% For intelligent document pro...
```
### Import data to your project
To import data, provide a list of files or folders
```
kili project import \\
reference_image.png datasets/defect_detection/ \\
--project-id cl4ljd3awc5gj0lpbb89nbcqg \\
--verbose
```
Ouputs:
```
datasets/defect_detection/visit1.mp4 SKIPPED
datasets/defect_detection/visit2.mp4 SKIPPED
Paths either do not exist, are filtered out or point towards wrong data type for the project

567 files have been successfully imported
```
### Import labels to your project
To import labels, provide a CSV file with two columns, separated by a semi-column:
- `external_id`: external id for which you want to import labels.
- `json_response_path`: paths to the json files containing the json_response to upload.
!!! Examples "CSV file template"
```
external_id;json_response_path
asset1;./labels/label_asset1.json
asset2;./labels/label_asset2.json
```

```
kili project label \\
datasets/defect_detection/labels.csv \\
--project-id cl4ljd3awc5gj0lpbb89nbcqg
```

Outputs:

```
82 labels have been successfully imported
```

If you have run a pre-annotation model, you can also import labels as predictions.
These labels will be seen as pre-annotation in the labeling interface.

```
kili project label \\
datasets/defect_detection/predictions.csv \\
--project-id cl4ljd3awc5gj0lpbb89nbcqg \\
--prediction \\
--model-name YOLO-run-3
```

Outputs:

```
82 labels have been successfully imported
```

### Get metrics of your project

```
kili project describe \\
--project-id cl4ljd3awc5gj0lpbb89nbcqg
```

Ouputs:

```
Title Defect detection
Description Bottle defects on production line
Dataset KPIs
------------
Total number of assets 567
Number of remaining assets 485
Skipped assets 0
Progress 14.5%
Quality KPIs
------------
Project consensus 79
Project honeypot 22
Number of reviewed assets 76
Number of open issues 5
Number of solved issues 12
Number of open questions 2
Number of solved questions 9
```
File renamed without changes.
14 changes: 8 additions & 6 deletions kili/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,24 +341,26 @@ def import_labels(
The labels to import have to be in the Kili format and stored in a json file.
Labels to import are provided in a CSV file with two columns, separated by a semi-column:
- external_id: external id for which you want to import labels.
- json_response_path: paths to the json files containing the json_response to upload.
- `external_id`: external id for which you want to import labels.
- `json_response_path`: paths to the json files containing the json_response to upload.
\b
!!! Examples: "CSV file template"
!!! Examples "CSV file template"
```
external_id;json_response_path
asset1;./labels/label_asset1.json
asset2;./labels/label_asset2.json
```
\b
!!! Examples:
!!! Examples
To import default labels:
```
kili project label \\
path/to/file.csv \\
--project-id <project_id>
```
To import labels as predictions:
```
kili project label \\
path/to/file.csv \\
Expand All @@ -382,7 +384,7 @@ def import_labels(
create_predictions_arguments = generate_create_predictions_arguments(
label_paths, external_id_array, model_name, project_id)
kili.create_predictions(**create_predictions_arguments)
print(f"{len(external_id_array)} labels successfully uploaded")
print(f"{len(external_id_array)} labels have been successfully imported")

else:
for row in row_dict:
Expand All @@ -395,7 +397,7 @@ def import_labels(
label_asset_external_id=external_id,
json_response=json_response,
project_id=project_id)
print(f"{len(row_dict)} labels successfully uploaded")
print(f"{len(row_dict)} labels have been successfully imported")


def main() -> None:
Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ nav:
- Project Version: project_version.md
- User: user.md
- Command line interface:
- Getting Started: cli_getting_started.md
- Reference: cli_reference.md
- Getting Started: cli/index.md
- Reference: cli/reference.md

## Configuration
plugins:
Expand Down

0 comments on commit 77be1ec

Please sign in to comment.