Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

A client for the Microsoft Azure Custom Vision Service

Project description


This repository contains a simple Python client for the Custom Vision Service.


# first, train a model

from custom_vision_client import TrainingClient, TrainingConfig

azure_region = "southcentralus"
training_key = "my-training-key"  # from settings pane on

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_images(project_id, ["kitten.jpg"], "Cat")
training_client.add_training_images(project_id, ["akita.png", "spitz.png"], "Dog")
training_client.add_training_images(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

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)

Command-line interface

You can also interact with the Custom Vision Service via a command-line interface:

# first, train a model
python3 -m \
  --key="my-training-key" \
  --projectname="my-project-name" \

# then, use the model to predict:
python3 -m custom_vision_client.prediction \
  --key="my-prediction-key" \
  --projectid="my-project-id-from-training" \
  --modelid="my-model-id-from-training" \

The command-line interface assumes that your training images are organized in folders such that every folder contains all the training images for that label:

├── label_one
│   ├── image_1.jpg
│   ├── image_2.png
│   └── image_3.png
└── label_two
    ├── image_4.jpg
    └── image_5.jpg

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
custom_vision_client-0.0.8.tar.gz (5.6 kB) Copy SHA256 hash SHA256 Source None Nov 15, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page