Skip to content

Instantly share code, notes, and snippets.

@J3698
Created December 21, 2021 20:51
Show Gist options
  • Save J3698/830bcbfe557125cd389d8474a7123eca to your computer and use it in GitHub Desktop.
Save J3698/830bcbfe557125cd389d8474a7123eca to your computer and use it in GitHub Desktop.
@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