Created
March 30, 2020 08:58
-
-
Save setuc/38cafb857a4ba672773edaae665265c6 to your computer and use it in GitHub Desktop.
Azure Functions replacement __init__ for custom vision
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import json | |
| import azure.functions as func | |
| from .predict import predict_url, log_msg | |
| def main(req: func.HttpRequest) -> func.HttpResponse: | |
| image_url = req.params.get('img') | |
| logging.info('Image URL received: ' + image_url) | |
| results = predict_url(image_url) | |
| headers = { | |
| "Content-type": "application/json", | |
| "Access-Control-Allow-Origin": "*" | |
| } | |
| return func.HttpResponse(json.dumps(results), headers = headers) |
Author
Author
Now fix the predict_url function by adding these two lines for the initialization of weights. The first two lines of the function would look like this:
def predict_url(imageUrl):
log_msg("Loading the TF Model")
initialize()
Author
Your requirements file will look like this
azure-functions
numpy==1.17.3
tensorflow==2.0.0
flask
pillow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modify the predict file to provide a path for the model weight file and the file containing the labels.