Package: autodistill-azure-vision
Autodistill Azure Vision ModuleThis repository contains the code supporting the Azure Vision module for use withAutodistill.TheAzure Vision Image Analysis 4.0 APIenables you to detect objects in images.With this package, you can use the API to automatically label data for use in training a fine-tuned computer vision model.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 withRoboflow Inference.Read the fullAutodistill documentation.Read theAutodistill Azure Vision documentation.Installation[!NOTE]Using this project will incur billing charges for API calls to theAzure Vision Image Analysis 4.0 API.
Refer to theAzure Computer Vision pricingfor more information and to calculate your expected pricing. This package makes one API call per image you want to label.To use Azure Vision with autodistill, you need to install the following dependency:pipinstallautodistill-azure-visionNext, you will need tocreate an Azure account. Once you have an Azure account, create a "Computer vision" deployment in the "Azure AI services" dashboard in Azure.This deployment will give you two API keys and an endpoint URL. You will need one of these API keys and the endpoint URL to use this Autodistill module.Set your API key and endpoint URL in your environment:export AZURE_VISION_SUBSCRIPTION_KEY=<your api key>
export AZURE_VISION_ENDPOINT=<your endpoint>Use the quickstart below to start labeling images.QuickstartLabel a Single Imagefromautodistill_azure_visionimportAzureVisionfromautodistill.detectionimportCaptionOntology# define an ontology to map class names to our Azure Custom Vision 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 modelbase_model=AzureVision(ontology=CaptionOntology({"animal":"animal","a forklift":"forklift"}),endpoint=os.environ["AZURE_VISION_ENDPOINT"],subscription_key=os.environ["AZURE_VISION_SUBSCRIPTION_KEY"])results=base_model.predict("image.jpeg")print(results)# annotate predictions on an imageclasses=base_model.ontology.classes()box_annotator=sv.BoxAnnotator()labels=[f"{classes[class_id]}{confidence:0.2f}"for_,_,confidence,class_id,_indetections]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))Label a Folder of Imagesfromautodistill_azure_visionimportAzureVisionfromautodistill.detectionimportCaptionOntology# define an ontology to map class names to our Azure Custom Vision 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 modelbase_model=AzureVision(ontology=CaptionOntology({"animal":"animal","a forklift":"forklift"}),endpoint=os.environ["AZURE_VISION_ENDPOINT"],subscription_key=os.environ["AZURE_VISION_SUBSCRIPTION_KEY"])base_model.label("./context_images",extension=".jpeg")LicenseThis project is licensed under anMIT license.🏆 ContributingWe love your input! Please see the core Autodistillcontributing guideto get started. Thank you 🙏 to all our contributors!