Code Monkey home page Code Monkey logo

azure-customvision's Introduction

Overview

The Custom Vision Service is an Azure Cognitive Service that lets you build custom image classifiers. It makes it easy and fast to build, deploy, and improve an image classifier. The Custom Vision Service provides a REST API and a web interface to upload your images and train the classifier. The Custom Vision Service works best when the item you're trying to classify is prominent in your image. Few images are required to create a classifier or detector. 50 images per class are enough to start your prototype. The methods Custom Vision Service uses are robust to differences, which allows you to start prototyping with so little data. This means Custom Vision Service is not well suited to scenarios where you want to detect subtle differences. For example, minor cracks or dents in quality assurance scenarios.

System requirements

You must have the following to complete this lab:

  • Azure Subscription
  • Windows 10
  • Microsoft Visual Code (latest update)
  • PIP library
    • Pip install opencv-python
    • Pip install requests
    • Pip install azure-cognitiveservices-vision-customvision
    • Pip install matplotlib

Exercises

This Hands-on lab includes the following exercises:

  1. Create Azure Service
  2. Build image classify project by custom vision service
  3. Build image classify project by Python with visual studio code
  4. Build image object detection project by custom vision service

Estimated time to complete this lab: 90 minutes.

Exercise 1: Create Azure Service

  1. Login Azure portal with provide Azure subscription

  2. Create a Custom Vision Service

    • Create a new Resource Group, click Add at top panel. (remember Resource Group Name, please create all of services with this Resource Group)

    • Entry custom vision in Filter, you will find Custom Vision (Preview) in the list, choose this service and click create.

    • A new blade will open with information about the Custom Vision (Preview).

    • In the Custom Vision (Preview) blade, provide the requested information about your service as specified in the table below image.

    • Entry Name of your service select default resource group in Resource group section.

    • Click Create

Exercise 2: Build image classify project by custom vision service

  1. Download and unzip customvision.zip to C drive from https://iothubstorageaccts.blob.core.windows.net/cvpic/customvision.zip

  2. Open https://customvision.ai/ by Microsoft Edge

  3. Click sign in with provided azure subscription account. You will see below page once login.

  4. Click NEW PROJECT provide the requested information about your service as specified in the table below image.

    Entry Name of your project select resource group you create in Exercise 1 in Resource Group section, other by default.

    Click Create project

  5. Click Add images on the top of panel, locate to folder C;\Lab\customvision\gear_images\axes, select all of images by Ctrl + A, click Open, entry axes as tag at My Tag section

    Click Upload 79 files

    Do the same action for rest tags in C:\ gear_images\

  6. Click Train at left of top panel to train the model by provide images of each tag

    Waiting for training integration complete

    You will find Precision and Recall number of your trained model. Click Mark Default at top of panel

  7. Click Quick Test at left of top panel, entry

    https://www.alpinetrek.co.uk/1500_1500_90/002-0808/berghaus-baffin-island-shell-jacket-hardshell-jacket.jpg

    In Image URL section, click you will see test result like below

    Close output panel.

  8. Verify API by post URL endpoint. Click Predictions at top of panel, select result picture you just test, and click delete. Click View Endpoint

    Open Postman on the desktop, entry POST URL with first URL In above output panel. Entry header by key/value above

    Entry Body with raw and JSON format with

    {"Url": "https://www.alpinetrek.co.uk/1500_1500_90/002-0808/berghaus-baffin-island-shell-jacket-hardshell-jacket.jpg"}

    Click Send, you will see test result like below

Exercise 3: Build image classify project by Python with visual studio code

  1. Open Visual Studio Code on desktop, select Python 3.5 at left of bottom panel.

    clicK File at left of top panel, click Open File…, locate to C;\Lab\customvision\classify.py

    click Open

  2. Open portal https://customvision.ai/, click sign in if your session is expired. Click setting icon at left of top panel,

    Copy Training Key and Prediction Key under resource group you created in Exercise 1 (e.g. techsubmit not Limited trial). Replace training_key and prediction_key in classify.py

    Replace project name classifylabfreeze with a new project name, different from project created in Exercise 2

    Replace PredictionEndpoint with Prediction Key above

    Click F5, select Python at output command

    Waiting for process complete, you will see the whole project was created, image uploaded, trained and verified automatically. (you could open https://customvision.ai to check project status, e.g. how many images uploaded)

Exercise 4: Build image object detection project by custom vision service

  1. Open https://customvision.ai/ by Microsoft Edge

  2. Click sign in with provided azure subscription account. You will see below page once login.

  3. Click NEW PROJECT provide the requested information about your service as specified in the table below image.

    Entry Name of your project select resource group you create in Exercise 1 in Resource Group section, select Object Detection (preview) in Project Type section.

    Click Create project

  4. Click Add images on the top of panel, locate to folder C;\Lab\customvision\gear_images_detection, select all of images by Ctril + A, click Open

    Click Upload 251 files

  5. After uploaded all files, click first picture, select boundary of helmets in the picture and add tag helmets like below.

    Entry helmets in Add Region Tag section first time.

    Click next icon and do same action of rest of all pictures, it might take couple minutes. (you don’t need tag all of pictures, but at least 30 tagged pictures need)

  6. Click Train at left of top panel to train model by provide images of each tag.

  7. You will find Precision, Recall and M.A.P number of your trained model. Click Mark Default at top of panel

  8. Click Quick Test at left of top panel, entry. In Image URL section, click -> you will see test result like below

  9. Verify API by post URL endpoint.

    Click Predictions at top of panel, select result picture you just test, and click delete.

    Click View Endpoint

    Open Postman on the desktop, entry POST URL with first URL In above output panel. Entry header by key/value above

    Entry Body with raw and JSON format with

    {"Url": "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Cologne_Germany_Industrial-work-with-Personal-Protective-Equipment-04.jpg/1200px-Cologne_Germany_Industrial-work-with-Personal-Protective-Equipment-04.jpg"}

    Click Send, you will see test result like below

azure-customvision's People

Contributors

alezhao-zz 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.