Skip to content

Instantly share code, notes, and snippets.

@Tdual
Created September 30, 2018 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tdual/c4bdb0fbe9d9a48366319dddf45a24de to your computer and use it in GitHub Desktop.
Save Tdual/c4bdb0fbe9d9a48366319dddf45a24de to your computer and use it in GitHub Desktop.
old api of matrixflow
@app.route('/upload', method="POST")
def upload_file():
files = request.files
res = fma.upload_file(files)
if res["status"] == "success":
name = res["detail"]["name"]
id = res["detail"]["id"]
save_path = fma.get_save_path(id)
cutout_res = cutout_face(save_path, name, save_path)
if cutout_res["status"] == "error":
return put_response(cutout_res)
else:
res["detail"]["faceTotal"] = cutout_res["detail"]["number"]
circum_res = circumscribe_face(save_path, name, save_path)
if circum_res["status"] == "error":
return put_response(circum_res)
print(res)
return put_response(res)
@app.route('/images/<image_id>/face/<number>', method="GET")
def get_face(image_id, number):
fullpath = get_face_image_name(image_id, number)
with open(fullpath) as f:
image = f.read()
content_type = fma.get_content_type(fullpath)
return put_response(image, content_type=content_type)
@app.route('/images/<image_id>/rectangle', method="GET")
def get_rectangle(image_id):
fullpath = get_face_image_name(image_id,type="rect")
with open(fullpath) as f:
image = f.read()
content_type = fma.get_content_type(fullpath)
return put_response(image, content_type=content_type)
@app.route('/images/<image_id>/rectangle/indiviual/<number>', method="GET")
def get_rectangle_indiviual(image_id, number):
name = get_face_image_name(image_id, type="rect", full_path=False)
save_path = fma.get_save_path(image_id)
res = circumscribe_face(save_path, name[5:], save_path, int(number))
fullpath = save_path + "/" + name
with open(fullpath) as f:
image = f.read()
content_type = fma.get_content_type(fullpath)
return put_response(image, content_type=content_type)
@app.route('/images/<image_id>/probability', method="GET")
def get_probability(image_id):
res = prob.get_prob(image_id)
return put_response(res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment