https://github.com/ramanaditya/seasons-of-serverless-solution-lovely-ladoos
Serverless Solution of Predicting Accuracy of your ladoos, using Custom Vision API and Azure Functions
https://github.com/ramanaditya/seasons-of-serverless-solution-lovely-ladoos
api azure-functions blob-storage custom-vision postman prediction serverless
Last synced: 4 months ago
JSON representation
Serverless Solution of Predicting Accuracy of your ladoos, using Custom Vision API and Azure Functions
- Host: GitHub
- URL: https://github.com/ramanaditya/seasons-of-serverless-solution-lovely-ladoos
- Owner: ramanaditya
- License: mit
- Created: 2020-11-19T07:05:37.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-01T01:20:27.000Z (over 4 years ago)
- Last Synced: 2025-02-01T00:33:49.326Z (5 months ago)
- Topics: api, azure-functions, blob-storage, custom-vision, postman, prediction, serverless
- Language: JavaScript
- Homepage:
- Size: 3.01 MB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Seasons of Serverless: Solution, Lovely Ladoos
## Blogs
- [Medium](https://ramanaditya.medium.com/seasons-of-serverless-lovely-ladoos-8769724ef618)
- [dev.to](https://dev.to/ramanaditya/seasons-of-serverless-lovely-ladoos-3db6)## About
Each year at this time, we prepare something special to help you learn Serverless once and for all with a series of challenges. This year, we decided to feature seven unique challenges, one per week. Come join us!
- [Check Original Repo](https://github.com/microsoft/Seasons-of-Serverless)## Solution
The solution creates a Serverless Endpoint which is used to
- List all the images stored on the Azure Blob Storage
- Upload new image on the Azure Blob Storage
- Predict the already uploaded image using Custom Vision API## Pre-requisites
- Create Resource Group
- Create Azure Blob Storage
- Create a Container
- Deploy the Custom Vision API, you can use this [datasets](./datasets)
- Publish your prediction## Running the Serverless Functions
#### Clone the Project
```bash
git clone [email protected]:ramanaditya/Seasons-of-Serverless-Solution-Lovely-Ladoos.git
```#### Install Dependencies
```bash
npm install
```#### Export `.env` variables
```bash
export $(grep -v '^#' .env | xargs)
```> Required Environment Variables are given in the [.env.example](https://github.com/ramanaditya/Seasons-of-Serverless-Solution-Lovely-Ladoos/blob/main/.env.example)
#### Run the function locally
```bash
func start
```## Checking the Working of API endpoint
- Test API using [Postman](https://www.postman.com/)## Endpoints
**Base URL: http://localhost:7071**- /api/predict?imageurl=\
- /api/blobs### Requests
| endpoint | method | parameters | required |
| :--- | :---: | :---: | :---: |
| /api/predict | `GET` | imageurl=\ | True |
| /api/blobs | `GET` | | |
| | `POST` | | |### Response
#### `/api/blobs`: `GET`
```json
[
{
"name": "11624351181437143-11108a41.jpg",
"properties": {
"createdOn": "2020-11-18T17:19:44.000Z",
"lastModified": "2020-11-18T17:19:44.000Z",
"etag": "0x8D88BE624813E21",
"contentLength": 46337,
"contentType": "image/jpeg",
"contentEncoding": "",
"contentLanguage": "",
"contentMD5": {
"type": "Buffer",
"data": []
},
"contentDisposition": "",
"cacheControl": "",
"blobType": "BlockBlob",
"leaseStatus": "unlocked",
"leaseState": "available",
"serverEncrypted": true,
"accessTier": "Hot",
"accessTierInferred": true,
"Content-CRC64": ""
},
"objectReplicationMetadata": "",
"OrMetadata": "",
"imageUrl": "https://.blob.core.windows.net//11624351181437143-11108a41.jpg"
}
]
```#### `/api/blobs`: `POST`
```json
{
"message": {
"etag": "\"0x8D88C9867471CEB\"",
"lastModified": "2020-11-19T14:35:46.000Z",
"xMsContentCrc64": {
"type": "Buffer",
"data": [236, 13, 94, 16, 86, 9, 229, 124]
},
"clientRequestId": "####-####-####-####",
"requestId": "####-####-####-####",
"version": "2020-02-10",
"date": "2020-11-19T14:35:46.000Z",
"isServerEncrypted": true,
"content-length": "0",
"server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0"
},
"url": "https://.blob.core.windows.net//image (62).jpeg"
}
```#### `/api/predict?imageurl=`: `GET`
```json
[
{
"probability": "94.44%",
"tagId": "def6ab54-27d1-4604-9bd8-f05e8ec7bc13",
"tagName": "ladoo",
"tagType": "Regular"
},
{
"probability": "5.30%",
"tagId": "c0797ccb-bf83-46be-b07b-08d5f60100e1",
"tagName": "doughnut",
"tagType": "Regular"
},
{
"probability": "0.26%",
"tagId": "36c3a169-0f43-4bc7-ba0b-76845a97b607",
"tagName": "sesame",
"tagType": "Regular"
}
]
```## Resources
- [Visual Studio Code](https://code.visualstudio.com)
- [Azure Account](https://azure.microsoft.com)
- [Azure Command-Line Interface (CLI)](https://docs.microsoft.com/en-us/cli/azure/)
- [Azure Functions Extension](https://docs.microsoft.com/en-us/azure/azure-functions/)
- [Custom Vision](https://docs.microsoft.com/en-in/azure/cognitive-services/custom-vision-service/)
- [Azure Blob Storage](https://docs.microsoft.com/en-in/azure/storage/blobs/)## Contributors
- [Aditya Raman](https://twitter.com/_adityaraman)
- [Rama Soumya Naraparaju](https://www.linkedin.com/in/soumyanarapa-3a8740169/)