stm32-fmt-code/access_control_python_server/app.py

31 lines
675 B
Python
Raw Normal View History

2023-09-22 18:37:02 +00:00
from flask import Flask, request
import json
import cv2
import base64
import numpy as np
2023-09-22 19:08:10 +00:00
from deepface import DeepFace
2023-09-22 18:37:02 +00:00
app = Flask(__name__)
@app.route('/')
def home():
return '<h1>Ching Chong Bing Bong Ding Dong!!</h1>'
@app.route('/process_image', methods=['POST'])
def process_image():
print(request.data)
request_data = json.loads(request.data.decode("utf-8"))
img_nparr = np.frombuffer(base64.b64decode(request_data['image']), np.uint8)
img = cv2.imdecode(img_nparr,cv2.IMREAD_COLOR)
2023-09-22 19:39:07 +00:00
try:
racist_detector = DeepFace.analyze(img)
return racist_detector
except:
return []
2023-09-22 18:37:02 +00:00
if __name__ == '__main__':
app.run()