Coder Social home page Coder Social logo

kcm117 / blob-customvision-trainer Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 14 KB

Upload training images directly from Azure Blob storage to Azure Custom Vision Service

License: MIT License

Python 100.00%
azure-custom-vision python azure azure-blob-storage

blob-customvision-trainer's Introduction

Blob Storage to Custom Vision Uploader

Note: Early version, not fully tested.

This script is designed to pull images directly from a blob storage account and upload training images to the Custom Vision Service in batches. This is beneficial if you would like to upload images directly from Azure Blob Storage to Custom Vision Service, without having them on a publicly accessible URL or downloading them to local storage. You can run this script from a local machine, from an Azure VM, or anywhere you can execute Python Code and have internet connectivity!

Initial tests:

  • ~ 8 seconds to pull and upload 100 tagged images from Azure Blob Storage to Custom Vision Service. (Home PC)
  • ~45 seconds to pull and upload 1,000 tagged images from Azure Blob Storage to Custom Vision Service. (Azure VM)

Instructions:

  1. Keys - Create a keys.json file in the same directory as the script. You can use the keys_sample.json file as a template. This local file will contain your Azure Storage key, Custom Vision training key, and Custom Vision project id (which can be found in the project settings page).

    {
    "storage_key":"<YOUR STORAGE ACCOUNT KEY HERE>",
    "customvision_projectid":"<YOUR CUSTOM VISION PROJECT ID HERE>",
    "customvision_training_key":"<YOUR CUSTOM VISION TRAINING KEY HERE>"
    }
    
  2. Training Data - The script expects data to be structured in the blob storage account into different directories, with each directory containing files with specific tag(s). Examples with cats and dogs classification:

    • container_name/animals/train/cat/many_pictures_of_cats.jpg
    • container_name/animals/train/dog/many_pictures_of_dogs.jpg
  3. Script Execution:

    • Python Environment: Script was developed in Python 3.7.

      # Install libraries from the requirements.txt file
      pip install -r requirements.txt
      
      # Or install the libraries directly in your current Python environment.
      pip install azure-storage-blob azure-cognitiveservices-vision-customvision
      
    • The script expects the following arguments:

      customvisionblobuploader.py <storage account name> <container name> <blob prefix> <comma separated tags> <region>
      
      • storage account name: the name of your storage account
      • container name: the name of the container in your storage account which contains training images
      • blob prefix: the prefix of the blobs to be uploaded. E.g. if the training images for cats are in container_name/train/cat, then you put put "train/cat" as the blob prefix.
      • tags (comma separated): these are the tags you desire in the Custom Vision Service. Tags will be created in the project if they do not exist.
      • region: the azure region in which your custom vision service is deployed. examples: eastus2, southcentralus, northcentralus, etc.
    • Example usage:

      customvisionblobuploader.py kcmunninstoragev2 animals train/cat cat southcentralus
      

Next Steps:

  • After the images are uploaded, you can go into the Web GUI @ https://www.customvision.ai to train a new iteration of the model. I may expand this script later to include training options.

References:

blob-customvision-trainer's People

Contributors

kcm117 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.