Created
September 30, 2018 05:58
-
-
Save Tdual/c4bdb0fbe9d9a48366319dddf45a24de to your computer and use it in GitHub Desktop.
old api of matrixflow
This file contains 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('/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