autodistill-gcp-vision


Nameautodistill-gcp-vision JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/capjamesg/autodistill-gcp-vision
SummaryAutodistill Google Cloud Vision module for use in training a custom, fine-tuned model.
upload_time2023-10-27 08:58:19
maintainer
docs_urlNone
authorRoboflow
requires_python>=3.7
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <p>
    <a align="center" href="" target="_blank">
      <img
        width="850"
        src="https://media.roboflow.com/open-source/autodistill/autodistill-banner.png"
      >
    </a>
  </p>
</div>

# Autodistill GCP Vision Module

This repository contains the code supporting the [Google Cloud Object Localization API](https://cloud.google.com/vision/docs/object-localizer#vision_localize_objects-python) base model for use with [Autodistill](https://github.com/autodistill/autodistill).

With this repository, you can label images using the Google Cloud Object Localization API and train a fine-tuned model using the generated labels.

This is ideal if you want to train a model that you own on a custom dataset.

You can then use your trained model on your computer using Autodistill, or at the edge or in the cloud by deploying with [Roboflow Inference](https://inference.roboflow.com).

See our Autodistill modules for [AWS Rekognition](https://github.com/autodistill/autodistill-rekognition) and [Azure Custom Vision](https://github.com/autodistill/autodistill-azure-vision) if you are interested in using those services instead.

Read the full [Autodistill documentation](https://autodistill.github.io/autodistill/).

Read the [GCP Vision Autodistill documentation](https://autodistill.github.io/autodistill/base_models/gcp_vision/).

## Installation

> [!NOTE]  
> Using this project will incur billing charges for API calls to the Google Cloud Object Localization API. Refer to the [Google Cloud Vision pricing](https://cloud.google.com/vision/pricing) for more information. This package makes one API call per image you want to label.

To use the Google Cloud Object Localization API with autodistill, you need to install the following dependency:

```bash
pip install autodistill-gcp-vision
```

You will then need to authenticate with the `gcloud` CLI.

Learn [how to install gcloud](https://cloud.google.com/sdk/docs/install).

Learn [how to set up and authenticate with gcloud](https://cloud.google.com/sdk/docs/initializing).

## Quickstart

```python
from autodistill_gcp_vision import GCPVision
from autodistill.detection import CaptionOntology
import supervision as sv
import cv2

# define an ontology to map class names to our Google Cloud Object Localization API prompt
# the ontology dictionary has the format {caption: class}
# where caption is the prompt sent to the base model, and class is the label that will
# be saved for that caption in the generated annotations
# then, load the model
base_model = GCPVision(
    ontology=CaptionOntology(
        {
            "Person": "Person",
            "a forklift": "forklift"
        }
    )
)

detections = base_model.predict("image.jpeg")
print(detections)

# annotate predictions on an image
classes = base_model.ontology.classes()

box_annotator = sv.BoxAnnotator()

labels = [
	f"{classes[class_id]} {confidence:0.2f}"
	for _, _, confidence, class_id, _
	in detections
]

image = cv2.imread("image.jpeg")

annotated_frame = box_annotator.annotate(
	scene=image.copy(),
	detections=detections,
	labels=labels
)

sv.plot_image(image=annotated_frame, size=(16, 16))
```

## License

This project is licensed under an [MIT license](LICENSE).

## 🏆 Contributing

We love your input! Please see the core Autodistill [contributing guide](https://github.com/autodistill/autodistill/blob/main/CONTRIBUTING.md) to get started. Thank you 🙏 to all our contributors!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/capjamesg/autodistill-gcp-vision",
    "name": "autodistill-gcp-vision",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Roboflow",
    "author_email": "support@roboflow.com",
    "download_url": "https://files.pythonhosted.org/packages/1c/5d/2d8771cc065c349a1ddbd707654bc95d55fda8cf27068537a3720a9ca71e/autodistill-gcp-vision-0.1.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n  <p>\n    <a align=\"center\" href=\"\" target=\"_blank\">\n      <img\n        width=\"850\"\n        src=\"https://media.roboflow.com/open-source/autodistill/autodistill-banner.png\"\n      >\n    </a>\n  </p>\n</div>\n\n# Autodistill GCP Vision Module\n\nThis repository contains the code supporting the [Google Cloud Object Localization API](https://cloud.google.com/vision/docs/object-localizer#vision_localize_objects-python) base model for use with [Autodistill](https://github.com/autodistill/autodistill).\n\nWith this repository, you can label images using the Google Cloud Object Localization API and train a fine-tuned model using the generated labels.\n\nThis is ideal if you want to train a model that you own on a custom dataset.\n\nYou can then use your trained model on your computer using Autodistill, or at the edge or in the cloud by deploying with [Roboflow Inference](https://inference.roboflow.com).\n\nSee our Autodistill modules for [AWS Rekognition](https://github.com/autodistill/autodistill-rekognition) and [Azure Custom Vision](https://github.com/autodistill/autodistill-azure-vision) if you are interested in using those services instead.\n\nRead the full [Autodistill documentation](https://autodistill.github.io/autodistill/).\n\nRead the [GCP Vision Autodistill documentation](https://autodistill.github.io/autodistill/base_models/gcp_vision/).\n\n## Installation\n\n> [!NOTE]  \n> Using this project will incur billing charges for API calls to the Google Cloud Object Localization API. Refer to the [Google Cloud Vision pricing](https://cloud.google.com/vision/pricing) for more information. This package makes one API call per image you want to label.\n\nTo use the Google Cloud Object Localization API with autodistill, you need to install the following dependency:\n\n```bash\npip install autodistill-gcp-vision\n```\n\nYou will then need to authenticate with the `gcloud` CLI.\n\nLearn [how to install gcloud](https://cloud.google.com/sdk/docs/install).\n\nLearn [how to set up and authenticate with gcloud](https://cloud.google.com/sdk/docs/initializing).\n\n## Quickstart\n\n```python\nfrom autodistill_gcp_vision import GCPVision\nfrom autodistill.detection import CaptionOntology\nimport supervision as sv\nimport cv2\n\n# define an ontology to map class names to our Google Cloud Object Localization API prompt\n# the ontology dictionary has the format {caption: class}\n# where caption is the prompt sent to the base model, and class is the label that will\n# be saved for that caption in the generated annotations\n# then, load the model\nbase_model = GCPVision(\n    ontology=CaptionOntology(\n        {\n            \"Person\": \"Person\",\n            \"a forklift\": \"forklift\"\n        }\n    )\n)\n\ndetections = base_model.predict(\"image.jpeg\")\nprint(detections)\n\n# annotate predictions on an image\nclasses = base_model.ontology.classes()\n\nbox_annotator = sv.BoxAnnotator()\n\nlabels = [\n\tf\"{classes[class_id]} {confidence:0.2f}\"\n\tfor _, _, confidence, class_id, _\n\tin detections\n]\n\nimage = cv2.imread(\"image.jpeg\")\n\nannotated_frame = box_annotator.annotate(\n\tscene=image.copy(),\n\tdetections=detections,\n\tlabels=labels\n)\n\nsv.plot_image(image=annotated_frame, size=(16, 16))\n```\n\n## License\n\nThis project is licensed under an [MIT license](LICENSE).\n\n## \ud83c\udfc6 Contributing\n\nWe love your input! Please see the core Autodistill [contributing guide](https://github.com/autodistill/autodistill/blob/main/CONTRIBUTING.md) to get started. Thank you \ud83d\ude4f to all our contributors!\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Autodistill Google Cloud Vision module for use in training a custom, fine-tuned model.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/capjamesg/autodistill-gcp-vision"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df3b1325285af98f952478f5f4dee220090df5f74f2c016d4caffc8b6ba8eeb6",
                "md5": "1b6cea4d61a33eaa9121e02e588ac706",
                "sha256": "7709dca1f14d8baddcadb75785689f5cee3e83b6407216a0f3a1dab6cfa38b2f"
            },
            "downloads": -1,
            "filename": "autodistill_gcp_vision-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1b6cea4d61a33eaa9121e02e588ac706",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4972,
            "upload_time": "2023-10-27T08:58:18",
            "upload_time_iso_8601": "2023-10-27T08:58:18.213468Z",
            "url": "https://files.pythonhosted.org/packages/df/3b/1325285af98f952478f5f4dee220090df5f74f2c016d4caffc8b6ba8eeb6/autodistill_gcp_vision-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c5d2d8771cc065c349a1ddbd707654bc95d55fda8cf27068537a3720a9ca71e",
                "md5": "badfb620623d118b21166e0223552ea7",
                "sha256": "729d125c65b3dd5ca6a85099e090b1729e43c11975e43f1aef6c047de5208c74"
            },
            "downloads": -1,
            "filename": "autodistill-gcp-vision-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "badfb620623d118b21166e0223552ea7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4655,
            "upload_time": "2023-10-27T08:58:19",
            "upload_time_iso_8601": "2023-10-27T08:58:19.529413Z",
            "url": "https://files.pythonhosted.org/packages/1c/5d/2d8771cc065c349a1ddbd707654bc95d55fda8cf27068537a3720a9ca71e/autodistill-gcp-vision-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-27 08:58:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "capjamesg",
    "github_project": "autodistill-gcp-vision",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "autodistill-gcp-vision"
}
        
Elapsed time: 0.13825s