A client for the Microsoft Azure Custom Vision Service
Project description
py_custom_vision_client
This repository contains a simple Python client for the Custom Vision Service.
Usage
# first, train a model
from custom_vision_client import TrainingClient, TrainingConfig
azure_region = "southcentralus"
training_key = "my-training-key" # from settings pane on customvision.ai
training_client = TrainingClient(TrainingConfig(azure_region, training_key))
project_id = training_client.create_project("my-project-name").Id
training_client.create_tag(project_id, "Cat")
training_client.create_tag(project_id, "Dog")
training_client.add_training_image(project_id, "kitten.jpg", "Cat")
training_client.add_training_image(project_id, "akita.png", "Dog")
training_client.add_training_image(project_id, "best-animal-pals.jpg", "Cat", "Dog")
model_id = training_client.trigger_training(project_id).Id
# then, use the model to predict:
from custom_vision_client import PredictionClient, PredictionConfig
azure_region = "southcentralus"
prediction_key = "my-prediction-key" # from settings pane on customvision.ai
prediction_client = PredictionClient(PredictionConfig(azure_region, project_id, prediction_key))
predictions = prediction_client.classify_image("cat.jpg", model_id) # could also be a url to a file
best_prediction = max(predictions, key=lambda _: _.Probability)
print(best_prediction.Tag)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for custom_vision_client-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6de1c5323b078ad0e123d266f8c152790b3d167d517510b9732ece574468c35 |
|
MD5 | b0a6b858a746c53349e70b2cb8f30db9 |
|
BLAKE2b-256 | b1f7d31f2ba3ad8a006123dfdee539f129749fde8299fafb4d4a98459207dcb2 |