diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6763722f..3448d85a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -29,6 +29,7 @@ ## Motivation and Context + Closes #(issue) @@ -52,6 +53,7 @@ Closes #(issue) ## Google Colab (optional) + Colab link: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d418afe5..ebaa8433 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,13 +30,14 @@ repos: - id: ruff-format types_or: [ python, pyi, jupyter ] - # - repo: https://github.com/executablebooks/mdformat - # rev: 0.7.17 - # hooks: - # - id: mdformat - # additional_dependencies: - # - "mdformat-mkdocs[recommended]>=2.1.0" - # args: ["--number"] + - repo: https://github.com/executablebooks/mdformat + rev: 0.7.17 + hooks: + - id: mdformat + additional_dependencies: + - "mdformat-mkdocs[recommended]>=2.1.0" + args: ["--number"] + exclude: ^docs/ - repo: https://github.com/codespell-project/codespell rev: v2.4.1 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 538c78ea..9e8aca5c 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -21,20 +21,20 @@ community include: - Being respectful of differing opinions, viewpoints, and experiences - Giving and gracefully accepting constructive feedback - Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience + and learning from the experience - Focusing on what is best not just for us as individuals, but for the overall - community + community Examples of unacceptable behavior include: - The use of sexualized language or imagery, and sexual attention or advances of - any kind + any kind - Trolling, insulting or derogatory comments, and personal or political attacks - Public or private harassment - Publishing others' private information, such as a physical or email address, - without their explicit permission + without their explicit permission - Other conduct which could reasonably be considered inappropriate in a - professional setting + professional setting ## Enforcement Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a323b9e..2300a81e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -161,12 +161,14 @@ Before starting your work on the project, set up your development environment: 3. **Create and activate a virtual environment:** **On Linux/macOS:** + ```bash python3 -m venv .venv source .venv/bin/activate ``` **On Windows:** + ```cmd python -m venv .venv .venv\Scripts\activate @@ -199,25 +201,28 @@ Furthermore, we have integrated a pre-commit GitHub Action into our workflow. Th To run the pre-commit tool, follow these steps: 1. **Install pre-commit** (already included if you followed the installation steps above): - ```bash - uv sync --group dev - ``` + + ```bash + uv sync --group dev + ``` 2. **Navigate to the project's root directory** (if not already there). 3. **Run pre-commit checks**: - ```bash - uv run pre-commit run --all-files - ``` - This will execute the pre-commit hooks configured for this project. If any issues are found, the pre-commit tool will provide feedback on how to resolve them. Make the necessary changes and re-run the command until all issues are resolved. + ```bash + uv run pre-commit run --all-files + ``` + + This will execute the pre-commit hooks configured for this project. If any issues are found, the pre-commit tool will provide feedback on how to resolve them. Make the necessary changes and re-run the command until all issues are resolved. 4. **Install pre-commit as a git hook** (optional but recommended): - ```bash - uv run pre-commit install - ``` - This will automatically run pre-commit checks every time you make a `git commit`. + ```bash + uv run pre-commit install + ``` + + This will automatically run pre-commit checks every time you make a `git commit`. ### Docstrings @@ -236,14 +241,16 @@ The `supervision` documentation is stored in a folder called `docs`. The project To run the documentation locally: 1. **Install documentation dependencies** (if not already installed): - ```bash - uv sync --group docs - ``` + + ```bash + uv sync --group docs + ``` 2. **Start the documentation server**: - ```bash - uv run mkdocs serve - ``` + + ```bash + uv run mkdocs serve + ``` 3. **Access the documentation** at `http://127.0.0.1:8000` in your browser. diff --git a/README.md b/README.md index 43d7cf6f..4a81dd8a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ [![discord](https://img.shields.io/discord/1159501506232451173?logo=discord&label=discord&labelColor=fff&color=5865f2&link=https%3A%2F%2Fdiscord.gg%2FGbfgXGJ8Bk)](https://discord.gg/GbfgXGJ8Bk) [![built-with-material-for-mkdocs](https://img.shields.io/badge/Material_for_MkDocs-526CFE?logo=MaterialForMkDocs&logoColor=white)](https://squidfunk.github.io/mkdocs-material/) -
+
roboflow%2Fsupervision | Trendshift
@@ -70,21 +70,21 @@ len(detections) - 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). + 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 import get_model + ```python + import cv2 + import supervision as sv + from inference import get_model - image = cv2.imread(...) - model = get_model(model_id="yolov8s-640", api_key=) - result = model.infer(image)[0] - detections = sv.Detections.from_inference(result) + image = cv2.imread(...) + model = get_model(model_id="yolov8s-640", api_key=) + result = model.infer(image)[0] + detections = sv.Detections.from_inference(result) - len(detections) - # 5 - ``` + len(detections) + # 5 + ``` @@ -100,9 +100,7 @@ image = cv2.imread(...) detections = sv.Detections(...) box_annotator = sv.BoxAnnotator() -annotated_frame = box_annotator.annotate( - scene=image.copy(), - detections=detections) +annotated_frame = box_annotator.annotate(scene=image.copy(), detections=detections) ``` https://github.com/roboflow/supervision/assets/26109316/691e219c-0565-4403-9218-ab5644f39bce @@ -135,88 +133,88 @@ for path, image, annotation in ds: - load - ```python - dataset = sv.DetectionDataset.from_yolo( - images_directory_path=..., - annotations_directory_path=..., - data_yaml_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_pascal_voc( + images_directory_path=..., + annotations_directory_path=..., + ) - dataset = sv.DetectionDataset.from_coco( - images_directory_path=..., - annotations_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'] + ```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_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'] - ``` + 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=... - ) + ```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_pascal_voc( + images_directory_path=..., + annotations_directory_path=..., + ) - dataset.as_coco( - images_directory_path=..., - annotations_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=..., + ) + ```