description | languages | page_type | products | urlFragment | |||
---|---|---|---|---|---|---|---|
Code and tutorial for Rock-paper-scissors game used at Azure Custom Vision hands-on workshop |
|
sample |
|
rock-paper-scissors-customvision |
Code and tutorial for "Rock-paper-scissors" game used at Azure Custom Vision hands-on workshop.
Outline the file contents of the repository. It helps users navigate the codebase, build configuration and any related assets.
File/folder | Description |
---|---|
Step{1-7} |
Sample source code. |
.gitignore |
Define what to ignore at commit time. |
README.md |
This README file. |
LICENSE |
The license for the sample. |
- An Azure account with an active subscription. If you don’t have an Azure subscription, you can create an Azure free account
- Install NodeJS
- Open Azure Portal
- Click on Create a resource, search for Resource group in the Marketplace and click on it
- Click on Create to create new resource group
- Fill-in the form the following information for your resource group:
- Subscription: <your_subscription>
- Resource group RPS_ResourceGroup
- Region: West Europe
- Click Review + create
- Verify the values and click on Create
- Wait until the deployment of the resource group is complete and click on Go to resource group
- Open the resource group you have created. The resource group is empty
- Click on Create resources or + Create to create a new resource
- Search for Custom Vision in the Marketplace and click on it
- Click Create
- Fill-in the form the following information for your Custom Vision resource:
- Create options: Both
- Subscription: <your_subscription>
- Resource group: RPS_ResourceGroup
- Region: West Europe
- Name: CustomVisionRPS (or any available name)
- Training pricing tier: Free F0
- Prediction pricing tier: Free F0
- Click Review + create
- Verify the values and click on Create
- Wait until the deployment of the resource is complete
- Open your resource group, verify that you now have two resources with Custom Vision type and click on + Create to add another resource
- Search for Web App in the Marketplace and click on it
-
Click Create
-
Fill-in the form the following information for your AppService resource:
- Subscription: <your_subscription>
- Resource group: RPS_ResourceGroup
- Name: <choose_unique_name>
- Publish: Code
- Runtime stack: Node 16 LTS (or higher)
- Operating system: Windows
- Region: West Europe
-
Click on Change size for App Service Plan
- Select Dev / Test plan and F1 pricing tier, then click Apply
- Verify values and click Create
- Wait until the deployment of the Web App is complete and click on Go to resource
- In your new Web App, on the left panel go to Settings -> Configuration -> Application Settings
- Click on + New application setting
- Fill-in the following information:
- Setting name: SCM_DO_BUILD_DURING_DEPLOYMENT
- Value: true
- Click OK
- Click Save. This will enable build step when we deploy our NodeJS application later
- Open your resource group and verify that you have the following resources: App Service Plan, App Service, Application Insights and two Custom Vision
- Sign in Custom Vision using your Azure account
- Click New Project
-
Fill-in the form
- Name: RPS
- Resource: RPSCustomVision[F0]
- Project Types: Classification
- Classification Types: Multiclass
- Domains: General
-
Click Create project
- In Custom Vision project click Add images
- Select the images and click Open to add them
- Write an appropriate Tag for your images (for example, paper), press Enter and click Upload files
- Wait until upload is finished
- Repeat the process to add other group of images
- In Custom Vision project click on Train
- Select Quick Training and click Train
- Wait for training to finish. This process can take a few minutes
- Click on Quick Test
- Upload a test image
If the prediction of the test image is incorrect, you can correct it and select the right tag.
- Open Predictions tab
- Select the incorrectly predicted image
- Assign correct tag and click Save and close
- In Custom Vision project click Train
- Select Advanced Training, choose 1 hour for training budget, and click Train
- Wait for training to finish
- Open Performance tab, select the finished iteration and click Publish
- Fill-in Model name, select RPSCustomVision_Prediction as prediction resource and click Publish
- Click on Prediction URL to see your credentials
Application based on code from NodeJS app on Azure example.
- index.js - server-side logic
- public/index.html - WebApp HTML template
- public/css/app.css - WebApp CSS styles
- public/js/app.js - WebApp Javascript logic
Local development is the same for all the steps:
- Open "StepN" folder
- Run
npm install
- Run
npm start
- Open http://localhost:1337
Azure deployment is the same for all the steps:
- Open "StepN" folder
- Create zip archive with contents of "StepN" folder, except for node_modules folder
- Open <choose_unique_name>.scm.azurewebsites.net
- navigate to Tools -> Zip Push Deploy
- Drag-and-drop zip archive to /wwwroot
- Open <choose_unique_name>.azurewebsites.net and verify that site is running
Code changes are described in respective steps:
-
Step 1: After cloning the repository, you can either choose to develop locally or deploy to Azure
-
Step 2: Initalize camera, take a picture, and store it in canvas element
-
Step 3: Submit and receive a picture to
index.js
. Then, submit picture fromindex.js
to Custom Vision API. Finally, receive predictions from Custom Vision -
Step 4: Return best match prediction to client-side and render result to HTML page
-
Step 5: Add AI opponent and show opponents move
-
Step 6: Visualize counter and show results
-
Step 7: Download the Custom Vision model and use it locally with
tensorflow.js
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.