Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
onuralpszr authored Jan 5, 2024
2 parents 7b7a734 + e9ba3ca commit 98c0b8c
Show file tree
Hide file tree
Showing 33 changed files with 2,492 additions and 646 deletions.
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ All new functions and classes in `supervision` should include docstrings. This i

So far, **there is no type checking with mypy**. See [issue](https://github.com/roboflow-ai/template-python/issues/4).


Then, go back to your fork of the `supervision` repository, click "Pull Requests", and click "New Pull Request".

![Opening a pull request](https://media.roboflow.com/open_pr.png)
Expand Down Expand Up @@ -109,7 +108,7 @@ PRs must pass all tests and linting requirements before they can be merged.

The `supervision` documentation is stored in a folder called `docs`. The project documentation is built using `mkdocs`.

To run the documentation, install the project requirements with `poetry install dev`. Then, run `mkdocs serve` to start the documentation server.
To run the documentation, install the project requirements with `poetry install --with dev`. Then, run `mkdocs serve` to start the documentation server.

You can learn more about mkdocs on the [mkdocs website](https://www.mkdocs.org/).

Expand Down
178 changes: 101 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

<br>

[notebooks](https://github.com/roboflow/notebooks) | [inference](https://github.com/roboflow/inference) | [autodistill](https://github.com/autodistill/autodistill) | [collect](https://github.com/roboflow/roboflow-collect)
[notebooks](https://github.com/roboflow/notebooks) | [inference](https://github.com/roboflow/inference) | [autodistill](https://github.com/autodistill/autodistill) | [collect](https://github.com/roboflow/roboflow-collect)

<br>

[![version](https://badge.fury.io/py/supervision.svg)](https://badge.fury.io/py/supervision)
[![downloads](https://img.shields.io/pypi/dm/supervision)](https://pypistats.org/packages/supervision)
[![license](https://img.shields.io/pypi/l/supervision)](https://github.com/roboflow/supervision/blob/main/LICENSE.md)
[![python-version](https://img.shields.io/pypi/pyversions/supervision)](https://badge.fury.io/py/supervision)
[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/roboflow/supervision/blob/main/demo.ipynb)
[![Gradio](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Roboflow/Annotators)
[![Discord](https://img.shields.io/discord/1159501506232451173)](https://discord.gg/GbfgXGJ8Bk)
[![version](https://badge.fury.io/py/supervision.svg)](https://badge.fury.io/py/supervision)
[![downloads](https://img.shields.io/pypi/dm/supervision)](https://pypistats.org/packages/supervision)
[![license](https://img.shields.io/pypi/l/supervision)](https://github.com/roboflow/supervision/blob/main/LICENSE.md)
[![python-version](https://img.shields.io/pypi/pyversions/supervision)](https://badge.fury.io/py/supervision)
[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/roboflow/supervision/blob/main/demo.ipynb)
[![Gradio](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Roboflow/Annotators)
[![Discord](https://img.shields.io/discord/1159501506232451173)](https://discord.gg/GbfgXGJ8Bk)

</div>

Expand Down Expand Up @@ -59,6 +59,30 @@ Supervision was designed to be model agnostic. Just plug in any classification,
5
```

<details>
<summary>👉 more model connectors</summary>

- inference

Running with [Inference](https://github.com/roboflow/inference) requires a [Roboflow API KEY](https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key).

```python
>>> import cv2
>>> import supervision as sv
>>> from inference.models.utils import get_roboflow_model

>>> image = cv2.imread(...)
>>> model = get_roboflow_model(model_id="yolov8s-640", api_key=<ROBOFLOW API KEY>)
>>> result = model.infer(image)[0]
>>> detections = sv.Detections.from_inference(result)

>>> len(detections)
>>> 5

```

</details>

### annotators

Supervision offers a wide range of highly customizable [annotators](https://supervision.roboflow.com/annotators/), allowing you to compose the perfect visualization for your use case.
Expand Down Expand Up @@ -104,88 +128,88 @@ Supervision provides a set of [utils](https://supervision.roboflow.com/datasets/

- load

```python
>>> dataset = sv.DetectionDataset.from_yolo(
... images_directory_path=...,
... annotations_directory_path=...,
... data_yaml_path=...
... )

>>> dataset = sv.DetectionDataset.from_pascal_voc(
... images_directory_path=...,
... annotations_directory_path=...
... )

>>> dataset = sv.DetectionDataset.from_coco(
... images_directory_path=...,
... annotations_path=...
... )
```
```python
>>> dataset = sv.DetectionDataset.from_yolo(
... images_directory_path=...,
... annotations_directory_path=...,
... data_yaml_path=...
... )

>>> dataset = sv.DetectionDataset.from_pascal_voc(
... images_directory_path=...,
... annotations_directory_path=...
... )

>>> dataset = sv.DetectionDataset.from_coco(
... images_directory_path=...,
... annotations_path=...
... )
```

- split

```python
>>> train_dataset, test_dataset = dataset.split(split_ratio=0.7)
>>> test_dataset, valid_dataset = test_dataset.split(split_ratio=0.5)
```python
>>> train_dataset, test_dataset = dataset.split(split_ratio=0.7)
>>> test_dataset, valid_dataset = test_dataset.split(split_ratio=0.5)

>>> len(train_dataset), len(test_dataset), len(valid_dataset)
(700, 150, 150)
```
>>> len(train_dataset), len(test_dataset), len(valid_dataset)
(700, 150, 150)
```

- merge

```python
>>> ds_1 = sv.DetectionDataset(...)
>>> len(ds_1)
100
>>> ds_1.classes
['dog', 'person']

>>> ds_2 = sv.DetectionDataset(...)
>>> len(ds_2)
200
>>> ds_2.classes
['cat']

>>> ds_merged = sv.DetectionDataset.merge([ds_1, ds_2])
>>> len(ds_merged)
300
>>> ds_merged.classes
['cat', 'dog', 'person']
```
```python
>>> ds_1 = sv.DetectionDataset(...)
>>> len(ds_1)
100
>>> ds_1.classes
['dog', 'person']

>>> ds_2 = sv.DetectionDataset(...)
>>> len(ds_2)
200
>>> ds_2.classes
['cat']

>>> ds_merged = sv.DetectionDataset.merge([ds_1, ds_2])
>>> len(ds_merged)
300
>>> ds_merged.classes
['cat', 'dog', 'person']
```

- save

```python
>>> dataset.as_yolo(
... images_directory_path=...,
... annotations_directory_path=...,
... data_yaml_path=...
... )

>>> dataset.as_pascal_voc(
... images_directory_path=...,
... annotations_directory_path=...
... )

>>> dataset.as_coco(
... images_directory_path=...,
... annotations_path=...
... )
```
```python
>>> dataset.as_yolo(
... images_directory_path=...,
... annotations_directory_path=...,
... data_yaml_path=...
... )

>>> dataset.as_pascal_voc(
... images_directory_path=...,
... annotations_directory_path=...
... )

>>> dataset.as_coco(
... images_directory_path=...,
... annotations_path=...
... )
```

- convert

```python
>>> sv.DetectionDataset.from_yolo(
... images_directory_path=...,
... annotations_directory_path=...,
... data_yaml_path=...
... ).as_pascal_voc(
... images_directory_path=...,
... annotations_directory_path=...
... )
```
```python
>>> sv.DetectionDataset.from_yolo(
... images_directory_path=...,
... annotations_directory_path=...,
... data_yaml_path=...
... ).as_pascal_voc(
... images_directory_path=...,
... annotations_directory_path=...
... )
```

</details>

Expand Down
Loading

0 comments on commit 98c0b8c

Please sign in to comment.