overwatch-sayak


Nameoverwatch-sayak JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/itz-sayak/overwatch_sayak
SummaryA set of easy-to-use utilities that will come in handy in a Computer Vision project
upload_time2024-06-18 11:21:50
maintainerSayak Dutta
docs_urlNone
authorSayak Dutta
requires_python<4.0,>=3.8
licenseMIT
keywords machine-learning deep-learning vision ml dl ai computer vision slided inference
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Overwatch Sayak

## Overview
The powers of this library  `overwatch-sayak` package can be used for object detection in images or video, loading datasets, detection tracking, counting, detecting, Slicing Aided Hyper Inferencing for small object detection, etc. 

## Installation
you need to install the `overwatch-sayak` package. You can do this using pip:

```bash
pip install overwatch-sayak
```
For importing the library for your code, use the import command with:

```python
import overwatch_sayak
```
## Quickstart
### Models
overwatch-sayak was designed to be model-friendly. Just plug in any classification, detection, or segmentation model. We have created connectors for the most popular libraries like Ultralytics, Transformers, or MMDetection for your convenience.

#### Inference
```python
import cv2
import overwatch_sayak as ov
from inference import get_model

image = cv2.imread("path/to/your/image.jpg")
model = get_model("yolov8s-640")
result = model.infer(image)[0]
detections = ov.Detections.from_inference(result)

len(detections)
# Output: Number of detections
```
### Annotators
overwatch-sayak offers a wide range of highly customizable annotators, allowing you to compose the perfect visualization for your use case.

```python
import cv2
import overwatch_sayak as ov

image = cv2.imread("path/to/your/image.jpg")
detections = ov.Detections(...)

bounding_box_annotator = ov.BoundingBoxAnnotator()
annotated_frame = bounding_box_annotator.annotate(
    scene=image.copy(),
    detections=detections
)

# Display or save the annotated image
cv2.imshow("Annotated Image", annotated_frame)
cv2.waitKey(0)
cv2.destroyAllWindows()
# Or save the image
cv2.imwrite("annotated_image.jpg", annotated_frame)
```
### Slicing Inference for Small Object Detection
Slicing the image into smaller pieces can improve object detection accuracy for detecting small objects. The following example demonstrates how to use the InferenceSlicer for this purpose.

```python
import overwatch_sayak as ov
from inference import get_model
import cv2
import numpy as np

# Load the image
image = cv2.imread("/path/to/image.jpg")

# Load the model
model = get_model("yolov8s-640")

# Define the callback function for slicing inference
def slicer_callback(slice: np.ndarray) -> ov.Detections:
    result = model.infer(slice)[0]
    detections = ov.Detections.from_inference(result)
    return detections

# Create the slicer
slicer = ov.InferenceSlicer(
    callback=slicer_callback,
    slice_wh=(512, 512),
    overlap_ratio_wh=(0.4, 0.4),
    overlap_filter_strategy=ov.OverlapFilter.NONE
)

# Run the slicer on the image
detections = slicer(image)

# Annotate the image
annotated_frame = ov.BoundingBoxAnnotator().annotate(
    scene=image.copy(),
    detections=detections
)

# Display or save the annotated image
cv2.imshow("Annotated Image", annotated_frame)
cv2.waitKey(0)
cv2.destroyAllWindows()
# Or save the image
cv2.imwrite("annotated_image.jpg", annotated_frame)
```
### Datasets
overwatch-sayak offers a suite of utilities that enable you to load, split, merge, and save datasets in various supported formats..

```python
import overwatch_sayak as ov

dataset = ov.DetectionDataset.from_yolo(
    images_directory_path="path/to/images",
    annotations_directory_path="path/to/annotations",
    data_yaml_path="path/to/data.yaml"
)

dataset.classes
# Output: ['dog', 'person']

len(dataset)
# Output: Number of images in the dataset
```
#### Split
```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)
# Output: (Number of training images, Number of test images, Number of validation images)
```
#### Merge
```python
ds_1 = ov.DetectionDataset(...)
len(ds_1)
# Output: Number of images in ds_1
ds_1.classes
# Output: ['dog', 'person']

ds_2 = ov.DetectionDataset(...)
len(ds_2)
# Output: Number of images in ds_2
ds_2.classes
# Output: ['cat']

ds_merged = ov.DetectionDataset.merge([ds_1, ds_2])
len(ds_merged)
# Output: Number of images in the merged dataset
ds_merged.classes
# Output: ['cat', 'dog', 'person']
```
#### Save
```python
dataset.as_yolo(
    images_directory_path="path/to/save/images",
    annotations_directory_path="path/to/save/annotations",
    data_yaml_path="path/to/save/data.yaml"
)

dataset.as_pascal_voc(
    images_directory_path="path/to/save/images",
    annotations_directory_path="path/to/save/annotations"
)

dataset.as_coco(
    images_directory_path="path/to/save/images",
    annotations_path="path/to/save/annotations"
)
```
#### Convert
```python
ov.DetectionDataset.from_yolo(
    images_directory_path="path/to/load/images",
    annotations_directory_path="path/to/load/annotations",
    data_yaml_path="path/to/load/data.yaml"
).as_pascal_voc(
    images_directory_path="path/to/save/images",
    annotations_directory_path="path/to/save/annotations"
)
```

## Contributing
If you want to contribute to this project, feel free to open an issue or submit a pull request on GitHub.

## License
This project is licensed under the MIT License.



 


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/itz-sayak/overwatch_sayak",
    "name": "overwatch-sayak",
    "maintainer": "Sayak Dutta",
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": "sayakdutta1002@gmail.com",
    "keywords": "machine-learning, deep-learning, vision, ML, DL, AI, Computer Vision, Slided Inference",
    "author": "Sayak Dutta",
    "author_email": "sayakdutta1002@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/28/2a/f154196088c3f9b324b10e5e47aac80d1a38e67aabaa4f68b3eccd5d28b3/overwatch_sayak-1.0.3.tar.gz",
    "platform": null,
    "description": "# Overwatch Sayak\n\n## Overview\nThe powers of this library  `overwatch-sayak` package can be used for object detection in images or video, loading datasets, detection tracking, counting, detecting, Slicing Aided Hyper Inferencing for small object detection, etc. \n\n## Installation\nyou need to install the `overwatch-sayak` package. You can do this using pip:\n\n```bash\npip install overwatch-sayak\n```\nFor importing the library for your code, use the import command with:\n\n```python\nimport overwatch_sayak\n```\n## Quickstart\n### Models\noverwatch-sayak was designed to be model-friendly. Just plug in any classification, detection, or segmentation model. We have created connectors for the most popular libraries like Ultralytics, Transformers, or MMDetection for your convenience.\n\n#### Inference\n```python\nimport cv2\nimport overwatch_sayak as ov\nfrom inference import get_model\n\nimage = cv2.imread(\"path/to/your/image.jpg\")\nmodel = get_model(\"yolov8s-640\")\nresult = model.infer(image)[0]\ndetections = ov.Detections.from_inference(result)\n\nlen(detections)\n# Output: Number of detections\n```\n### Annotators\noverwatch-sayak offers a wide range of highly customizable annotators, allowing you to compose the perfect visualization for your use case.\n\n```python\nimport cv2\nimport overwatch_sayak as ov\n\nimage = cv2.imread(\"path/to/your/image.jpg\")\ndetections = ov.Detections(...)\n\nbounding_box_annotator = ov.BoundingBoxAnnotator()\nannotated_frame = bounding_box_annotator.annotate(\n    scene=image.copy(),\n    detections=detections\n)\n\n# Display or save the annotated image\ncv2.imshow(\"Annotated Image\", annotated_frame)\ncv2.waitKey(0)\ncv2.destroyAllWindows()\n# Or save the image\ncv2.imwrite(\"annotated_image.jpg\", annotated_frame)\n```\n### Slicing Inference for Small Object Detection\nSlicing the image into smaller pieces can improve object detection accuracy for detecting small objects. The following example demonstrates how to use the InferenceSlicer for this purpose.\n\n```python\nimport overwatch_sayak as ov\nfrom inference import get_model\nimport cv2\nimport numpy as np\n\n# Load the image\nimage = cv2.imread(\"/path/to/image.jpg\")\n\n# Load the model\nmodel = get_model(\"yolov8s-640\")\n\n# Define the callback function for slicing inference\ndef slicer_callback(slice: np.ndarray) -> ov.Detections:\n    result = model.infer(slice)[0]\n    detections = ov.Detections.from_inference(result)\n    return detections\n\n# Create the slicer\nslicer = ov.InferenceSlicer(\n    callback=slicer_callback,\n    slice_wh=(512, 512),\n    overlap_ratio_wh=(0.4, 0.4),\n    overlap_filter_strategy=ov.OverlapFilter.NONE\n)\n\n# Run the slicer on the image\ndetections = slicer(image)\n\n# Annotate the image\nannotated_frame = ov.BoundingBoxAnnotator().annotate(\n    scene=image.copy(),\n    detections=detections\n)\n\n# Display or save the annotated image\ncv2.imshow(\"Annotated Image\", annotated_frame)\ncv2.waitKey(0)\ncv2.destroyAllWindows()\n# Or save the image\ncv2.imwrite(\"annotated_image.jpg\", annotated_frame)\n```\n### Datasets\noverwatch-sayak offers a suite of utilities that enable you to load, split, merge, and save datasets in various supported formats..\n\n```python\nimport overwatch_sayak as ov\n\ndataset = ov.DetectionDataset.from_yolo(\n    images_directory_path=\"path/to/images\",\n    annotations_directory_path=\"path/to/annotations\",\n    data_yaml_path=\"path/to/data.yaml\"\n)\n\ndataset.classes\n# Output: ['dog', 'person']\n\nlen(dataset)\n# Output: Number of images in the dataset\n```\n#### Split\n```python\ntrain_dataset, test_dataset = dataset.split(split_ratio=0.7)\ntest_dataset, valid_dataset = test_dataset.split(split_ratio=0.5)\n\nlen(train_dataset), len(test_dataset), len(valid_dataset)\n# Output: (Number of training images, Number of test images, Number of validation images)\n```\n#### Merge\n```python\nds_1 = ov.DetectionDataset(...)\nlen(ds_1)\n# Output: Number of images in ds_1\nds_1.classes\n# Output: ['dog', 'person']\n\nds_2 = ov.DetectionDataset(...)\nlen(ds_2)\n# Output: Number of images in ds_2\nds_2.classes\n# Output: ['cat']\n\nds_merged = ov.DetectionDataset.merge([ds_1, ds_2])\nlen(ds_merged)\n# Output: Number of images in the merged dataset\nds_merged.classes\n# Output: ['cat', 'dog', 'person']\n```\n#### Save\n```python\ndataset.as_yolo(\n    images_directory_path=\"path/to/save/images\",\n    annotations_directory_path=\"path/to/save/annotations\",\n    data_yaml_path=\"path/to/save/data.yaml\"\n)\n\ndataset.as_pascal_voc(\n    images_directory_path=\"path/to/save/images\",\n    annotations_directory_path=\"path/to/save/annotations\"\n)\n\ndataset.as_coco(\n    images_directory_path=\"path/to/save/images\",\n    annotations_path=\"path/to/save/annotations\"\n)\n```\n#### Convert\n```python\nov.DetectionDataset.from_yolo(\n    images_directory_path=\"path/to/load/images\",\n    annotations_directory_path=\"path/to/load/annotations\",\n    data_yaml_path=\"path/to/load/data.yaml\"\n).as_pascal_voc(\n    images_directory_path=\"path/to/save/images\",\n    annotations_directory_path=\"path/to/save/annotations\"\n)\n```\n\n## Contributing\nIf you want to contribute to this project, feel free to open an issue or submit a pull request on GitHub.\n\n## License\nThis project is licensed under the MIT License.\n\n\n\n \n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A set of easy-to-use utilities that will come in handy in a Computer Vision project",
    "version": "1.0.3",
    "project_urls": {
        "Documentation": "https://github.com/itz-sayak/overwatch_sayak/blob/main/README.md",
        "Homepage": "https://github.com/itz-sayak/overwatch_sayak",
        "Repository": "https://github.com/itz-sayak/overwatch_sayak"
    },
    "split_keywords": [
        "machine-learning",
        " deep-learning",
        " vision",
        " ml",
        " dl",
        " ai",
        " computer vision",
        " slided inference"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0e26f0ab79888aaa39f5be5341318e76874028fc9f1e309aa76c5a99697b1e23",
                "md5": "d5ad385698a2623db3b3565e65eccbc5",
                "sha256": "9ec7a41a8f1b39e1e161771703be7ab7fa32572529db03f9aa21963cd8efb5d2"
            },
            "downloads": -1,
            "filename": "overwatch_sayak-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d5ad385698a2623db3b3565e65eccbc5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 121188,
            "upload_time": "2024-06-18T11:21:45",
            "upload_time_iso_8601": "2024-06-18T11:21:45.613228Z",
            "url": "https://files.pythonhosted.org/packages/0e/26/f0ab79888aaa39f5be5341318e76874028fc9f1e309aa76c5a99697b1e23/overwatch_sayak-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "282af154196088c3f9b324b10e5e47aac80d1a38e67aabaa4f68b3eccd5d28b3",
                "md5": "ba088906432ab52d3189478439c92fde",
                "sha256": "d1cc5ef1a1169e959321560f86314e89989c4f92e86540d8e12ab952cebf418d"
            },
            "downloads": -1,
            "filename": "overwatch_sayak-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ba088906432ab52d3189478439c92fde",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 101106,
            "upload_time": "2024-06-18T11:21:50",
            "upload_time_iso_8601": "2024-06-18T11:21:50.064924Z",
            "url": "https://files.pythonhosted.org/packages/28/2a/f154196088c3f9b324b10e5e47aac80d1a38e67aabaa4f68b3eccd5d28b3/overwatch_sayak-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-18 11:21:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "itz-sayak",
    "github_project": "overwatch_sayak",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "overwatch-sayak"
}
        
Elapsed time: 0.89352s