Created
December 21, 2021 20:51
-
-
Save J3698/830bcbfe557125cd389d8474a7123eca to your computer and use it in GitHub Desktop.
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
@app.route("/classify") | |
@cross_origin() | |
def classify_symbol(): | |
json_str = request.args.get('points') | |
if json_str is None: | |
return {"top5": [" ", " ", " ", " ", " "]} | |
json_data = json.loads(json_str) | |
if 'data' not in json_data: | |
return {"top5": [" ", " ", " ", " ", " "]} | |
points = json_data['data'] | |
if len(points) == 1 and len(points[0]) == 0: | |
return {"top5": [" ", " ", " ", " ", " "]} | |
points_to_image(points) | |
tensor = ToTensor()(Image.open("test.png").convert('RGB')) | |
tensor = torch.unsqueeze(tensor, 0) | |
output = model(tensor) | |
pred = fix_predictions(output) | |
return {"top5": pred} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment