diff --git a/CITATION.cff b/CITATION.cff index 88df70c7e..093d8807e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ cff-version: 1.2.0 author: Roboflow message: If you use this software, please cite it as below. title: supervision -version: 0.9.0 +version: 0.10.0 date-released: 2023-01-19 license: MIT repository-code: https://github.com/roboflow/supervision diff --git a/README.md b/README.md index 568d29f58..0232e631a 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,22 @@ pip install -e ".[dev]" ... annotations_directory_path='...' ... ) ``` + +- Load classification datasets in one of supported formats + + ```python + >>> cs = sv.ClassificationDataset.from_folder_structure( + ... root_directory_path='...' + ... ) + ``` + +- Save classification datasets in one of supported formats + + ```python + >>> cs.as_folder_structure( + ... root_directory_path='...' + ... ) + ``` diff --git a/docs/changelog.md b/docs/changelog.md index 3dfa682cb..1224fbc34 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,56 +1,47 @@ -### 0.9.0 June 7, 2023 +### 0.10.0 June 14, 2023 -- Added [[#118](https://github.com/roboflow/supervision/pull/118)]: ability to select [`sv.Detections`](https://roboflow.github.io/supervision/detection/core/#supervision.detection.core.Detections.__getitem__) by index, list of indexes or slice. Here is an example illustrating the new selection methods. +- Added [[#125](https://github.com/roboflow/supervision/pull/125)]: ability to load and save [`sv.ClassificationDataset`](https://roboflow.github.io/supervision/dataset/core/#classificationdataset) in a folder structure format. ```python >>> import supervision as sv ->>> detections = sv.Detections(...) ->>> len(detections[0]) -1 ->>> len(detections[[0, 1]]) -2 ->>> len(detections[0:2]) -2 +>>> cs = sv.ClassificationDataset.from_folder_structure( +... root_directory_path='...' +... ) + +>>> cs.as_folder_structure( +... root_directory_path='...' +... ) ``` -- Added [[#101](https://github.com/roboflow/supervision/pull/101)]: ability to extract masks from YOLOv8 result using [`sv.Detections.from_yolov8`](https://roboflow.github.io/supervision/detection/core/#supervision.detection.core.Detections.from_yolov8). Here is an example illustrating how to extract boolean masks from the result of the YOLOv8 model inference. +- Added [[#125](https://github.com/roboflow/supervision/pull/125)]: support for [`sv.ClassificationDataset.split`](https://roboflow.github.io/supervision/dataset/core/#supervision.dataset.core.ClassificationDataset.split) allowing to divide `sv.ClassificationDataset` into two parts. -```python ->>> import cv2 ->>> from ultralytics import YOLO ->>> import supervision as sv +- Added [[#110](https://github.com/roboflow/supervision/pull/110)]: ability to extract masks from Roboflow API results using [`sv.Detections.from_roboflow`](https://roboflow.github.io/supervision/detection/core/#supervision.detection.core.Detections.from_roboflow). ->>> image = cv2.imread(...) ->>> image.shape -(640, 640, 3) +- Added [[commit hash](https://github.com/roboflow/supervision/commit/d000292eb2f2342544e0947b65528082e60fb8d6)]: Supervision Quickstart [notebook](https://colab.research.google.com/github/roboflow/supervision/blob/main/demo.ipynb) where you can learn more about Detection, Dataset and Video APIs. ->>> model = YOLO('yolov8s-seg.pt') ->>> result = model(image)[0] ->>> detections = sv.Detections.from_yolov8(result) ->>> detections.mask.shape -(2, 640, 640) -``` +- Changed [[#135](https://github.com/roboflow/supervision/pull/135)]: `sv.get_video_frames_generator` documentation to better describe actual behavior. -- Added [[#122](https://github.com/roboflow/supervision/pull/122)]: ability to crop image using [`sv.crop`](https://roboflow.github.io/supervision/utils/image/#crop). Here is an example showing how to get a separate crop for each detection in `sv.Detections`. +### 0.9.0 June 7, 2023 + +- Added [[#118](https://github.com/roboflow/supervision/pull/118)]: ability to select [`sv.Detections`](https://roboflow.github.io/supervision/detection/core/#supervision.detection.core.Detections.__getitem__) by index, list of indexes or slice. Here is an example illustrating the new selection methods. ```python ->>> import cv2 >>> import supervision as sv ->>> image = cv2.imread(...) >>> detections = sv.Detections(...) ->>> len(detections) +>>> len(detections[0]) +1 +>>> len(detections[[0, 1]]) 2 ->>> crops = [ -... sv.crop(image=image, xyxy=xyxy) -... for xyxy -... in detections.xyxy -... ] ->>> len(crops) +>>> len(detections[0:2]) 2 ``` +- Added [[#101](https://github.com/roboflow/supervision/pull/101)]: ability to extract masks from YOLOv8 result using [`sv.Detections.from_yolov8`](https://roboflow.github.io/supervision/detection/core/#supervision.detection.core.Detections.from_yolov8). Here is an example illustrating how to extract boolean masks from the result of the YOLOv8 model inference. + +- Added [[#122](https://github.com/roboflow/supervision/pull/122)]: ability to crop image using [`sv.crop`](https://roboflow.github.io/supervision/utils/image/#crop). Here is an example showing how to get a separate crop for each detection in `sv.Detections`. + - Added [[#120](https://github.com/roboflow/supervision/pull/120)]: ability to conveniently save multiple images into directory using [`sv.ImageSink`](https://roboflow.github.io/supervision/utils/image/#imagesink). Here is an example showing how to save every tenth video frame as a separate image. ```python diff --git a/setup.py b/setup.py index b8ef2774c..68ce328e6 100644 --- a/setup.py +++ b/setup.py @@ -64,6 +64,6 @@ def get_version(): 'Operating System :: Unix', 'Operating System :: MacOS' ], - keywords="machine-learning, deep-learning, vision, ML, DL, AI, YOLOv5, YOLOv8, Roboflow", + keywords="machine-learning, deep-learning, vision, ML, DL, AI, YOLOv5, YOLOv8, SAM, Roboflow", python_requires='>=3.7', ) diff --git a/supervision/__init__.py b/supervision/__init__.py index 28bd6d8de..3fafef8cb 100644 --- a/supervision/__init__.py +++ b/supervision/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.9.0" +__version__ = "0.10.0" from supervision.classification.core import Classifications from supervision.dataset.core import ( diff --git a/supervision/dataset/core.py b/supervision/dataset/core.py index 24a8f0fcf..96c0be2b8 100644 --- a/supervision/dataset/core.py +++ b/supervision/dataset/core.py @@ -396,7 +396,7 @@ def split( ) return train_dataset, test_dataset - def as_multiclass_folder_structure(self, root_directory_path: str) -> None: + def as_folder_structure(self, root_directory_path: str) -> None: """ Saves the dataset as a multi-class folder structure. @@ -421,9 +421,7 @@ def as_multiclass_folder_structure(self, root_directory_path: str) -> None: cv2.imwrite(image_path, image) @classmethod - def from_multiclass_folder_structure( - cls, root_directory_path: str - ) -> ClassificationDataset: + def from_folder_structure(cls, root_directory_path: str) -> ClassificationDataset: """ Load data from a multiclass folder structure into a ClassificationDataset. @@ -446,7 +444,7 @@ def from_multiclass_folder_structure( >>> project = rf.workspace(WORKSPACE_ID).project(PROJECT_ID) >>> dataset = project.version(PROJECT_VERSION).download("folder") - >>> cd = sv.ClassificationDataset.from_multiclass_folder_structure( + >>> cd = sv.ClassificationDataset.from_folder_structure( ... root_directory_path=f"{dataset.location}/train" ... ) ```