-
-
Notifications
You must be signed in to change notification settings - Fork 434
Expand file tree
/
Copy pathembedding_server.py
More file actions
23 lines (22 loc) · 896 Bytes
/
embedding_server.py
File metadata and controls
23 lines (22 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- coding: utf-8 -*-
import os
from flask import Flask, request, jsonify
import FaceProcessing
from faces import save_embedding
# Initialize the Flask application
app = Flask(__name__)
# route http posts to this method
BASEDIR = os.getenv('RUNTIME_BASEDIR',os.path.abspath(os.path.dirname(__file__)))
@app.route('/api/embedding', methods=['POST'])
def embedding():
embedding = FaceProcessing.FaceProcessingBase64ImageData2(request.data)
embedding_str = save_embedding.convert_embedding_to_string(embedding)
print(embedding_str)
return jsonify({'embedding':embedding_str}), 200
if __name__ == '__main__':
FaceProcessing.init_embedding_processor()
print("start to warm up")
embedding = FaceProcessing.FaceProcessingImageData2(os.path.join(BASEDIR,"image","Mike_Alden_0001_tmp.png"))
print("warmed up")
print(embedding)
app.run(host="0.0.0.0", port=6000)