View on GitHub

Ready-to-use Presentations

Pick a topic to present with ready-made presentations!

Integrating Custom Vision with Power Apps for Diabetic Retinopathy Detection

https://docs.microsoft.com/learn/modules/classify-images-custom-vision/

https://docs.microsoft.com/learn/modules/customize-apps-in-powerapps/

Goals

In this workshop, we will discuss how to build a no-code app with Custom Vision to classify images

Goal Description
What will you learn How to build an app with Power Apps and integrate Custom Vision to classify images
What you’ll need Custom Vision, Power App
Duration 1 hour
Just want to try the app or see the solution? DR Detection App
Slides Powerpoint
Author Jingyi Zhu, Sanya Sinha

Video

workshop walk-through

🎥 Click this image to watch Jingyi and Sanya walk you through the workshop

Pre-Learning

Get started with Computer Vision

Get started with Power App

Prerequisites

  1. You’ll need to have an Azure Account for Custom Vision Service. You may get free credits from Azure for Students, or Azure Free Trial.

    Learn more about creating an Azure Account at Microsoft Learn

  2. Moreover, If you haven’t already, sign up for free at PowerApps.com with a work or school account. Once you’ve signed up, you’ll be able to sign in to PowerApps on the web.

    Learn more about joining Microsoft Developer program and creating a PowerApp Account

What students will learn

In this project, you will build an app that detect Diabetic Retinopathy

You will be able to…

  1. Draw automatic & accurate detection insights from datasets
  2. Use the Custom Vision service to create an image classification solution
  3. Customize a Power app by adding controls, images, and logic.

What is Diabetic Retinopathy? A diabetes complication that affects eyes, which might cause no symptoms or only mild vision problems at first. But it can lead to blindness. Careful management of diabetes is the best way to prevent vision loss. Patient should see an eye doctor for a yearly eye exam with dilation — even if the vision seems fine.

eye image

Milestone 1 - Custom Vision project build up

In Azure, you can use the Custom Vision cognitive service to train an image classification model based on existing images. There are two elements to creating an image classification solution. First, you must train a model to recognize different classes using existing images. Then, when the model is trained you must publish it as a service that can be consumed by applications.

  1. Let’s begin by getting the dataset of diabetic retinopathy images

    https://www.kaggle.com/linchundan/fundusimage1000

    https://www5.cs.fau.de/fileadmin/research/datasets/fundus-images/healthy.zip

    You are free to amalgamate both these datasets to strengthen the robustness of your model.

  2. Open the Azure portal at https://portal.azure.com/. If prompted, sign in using the Microsoft account associated with your Azure subscription and agree to the terms of service screenshot 1

  3. Click the Custom Vision section, then you’ll enter this page: screenshot 2

    • Let’s create a new project with the following settings:

      Create options: Both

      Project Details:

      Subscription: Visual Studio Enterprise Subscription 
            
      Resource group: DRDEMO 
      

      Instance Details:

      Region: the one closest to you
      
      Name: DRDEMO101
      

      Training and Prediction Resource:

      Pricing tier: Standard
      

    Click ‘Review+create’. Once your resource is validated, hit ‘Create’.
    You will now have the resource group available screenshot 3

  4. Next, login to the Custom Vision portal, create a new project with the following settings:

    screenshot 4

       Name: Diabetic Retinopathy detection 
    
       Description: Image classification for Diabetic Retinopathy
    
       Resource: The resource you created previously
    
       Project Types: Classification
    
       Classification Types: Multiclass (single tag per image)
    
       Domains: General[A2] Then, click 'Create Project'
    
  5. You will enter the User Interface of Custom Vision like the one below. Click [+] Add images, and select all of the files in the positive image folder you extracted previously. Then upload the image files, specifying the tag positive custom vision portal

  6. Repeat the previous step to upload the images in the negative folder with the tag negative

  7. In the Custom Vision project, above the images, click Train to train a classification model using the tagged images. Select the Quick Training option, and then wait for the training iteration to complete (this may take a minute or so).

  8. When the model iteration has been trained, review the Precision, Recall, and AP performance metrics - these measure the prediction accuracy of the classification model, and should all be high.

    • Precision indicates the fraction of identified classifications that were correct. For example, if the model identified 100 images as dogs, and 99 of them were actually of dogs, then the precision would be 99%.
    • Recall indicates the fraction of actual classifications that were correctly identified. For example, if there were actually 100 images of apples, and the model identified 80 as apples, the recall would be 80%.
    • Mean average precision is the average value of the average precision (AP). AP is the area under the precision/recall curve (precision plotted against recall for each prediction made). cv training

Before publishing this iteration of the model for applications to use, you should test it.

  1. Above the performance metrics, click ‘Quick Test’. View the predictions returned by your model - the probability score should be around 90%
  2. In the Quick Test window, select in the Submit Image field and enter the URL of the image you want to use for your test. If you want to use a locally stored image instead, select the Browse local files button and select a local image file.
  3. The image you select appears in the middle of the page. Then the prediction results appear below the image in the form of a table with two columns, labeled Tags and Confidence. After you view the results, you may close the Quick Test window. quick test window

Now you’re ready to publish your trained model and use it from a client application!

Click Publish to publish the trained model with the following settings:

    Model name: Diabetic Retinopathy detection 

    Prediction Resource: The prediction resource you created previously.

After publishing, click the Prediction URL icon to see information required to use the published model. Later, you will need the appropriate URL and Prediction-Key values to get a prediction from an Image URL, so keep this dialog box open and carry on to the next task.

Go to https://make.powerapps.com and sign in with your organizational account.

The following figure shows the main development window when you enter Power Apps Studio:

studio 1

studio 2

Now we will have a look at the steps to connecting our application to Custom Vision

  1. We need to connect to Custom Vision by going Data source→(search Custom Vision) → Select Custom Vision → Choose a table/entity. connect 1
  2. Then you will be asked to enter the Prediction Key and Site URL. We’ll go back to Custom Vision Performance tab and find the Prediction Key like the image below (We covered the specific keys to avoid cost of reusing resources) connect 2

We’ll use only a portion of the image file URL like the image below connect 3

Click ‘Connect’ then your Custom Vision data resource will appear in your left pane!

Milestone 4 - Layout of Power App

Now, we’ll create the ‘CameraTestScreen’

layout 2

The second screen is ‘GalleryTestScreen’, which looks like this layout 7

Moving forward, we’ll build up the navigation screen when you enter the app. layout 12

After performing all the above steps, you get a Power Apps with screens and functions which will look like the image below. layout 17

The app can run on mobile, install the Power Apps Mobile app on your phone. When building an app, you should test it in the same form factor as your users!

Milestone 5 - App accuracy test with new inputs

Now that your app is built, the next step is to start testing it.

Unit test

End-to-end test

User acceptance test (Optional)

Congratulations! You made your first app, and it’s tested and ready to go! Now you can publish and share your canvas app!

Knowledge check

https://docs.microsoft.com/learn/modules/classify-images-custom-vision/3a-knowledge-check

https://docs.microsoft.com/learn/modules/get-started-with-powerapps/6-powerapps-quiz-get-started

Next steps

Learning more about Custom Vision

Learning more about Canvas App creation

Azure Health bot by using built-in or custom scenarios

AI business school for healthcare

The Value of Computer Vision in Healthcare Panel in this video

Practice your skills

You can modify your app to analyze images, including generating a descriptive caption, extracting relevant tags, identifying objects, determining image type and metadata, detecting human faces, known brands, and celebrities, and others. You can find out more about using the Computer Vision service in the service documentation.

With Power Apps, you can:

Build an app quickly by using the skills that you already have.

Connect to the cloud services and data sources that you’re already using.

Share your apps instantly so that coworkers can use them on their phones and tablets.

Feedback

Be sure to give feedback about this workshop!

Code of Conduct