Spaces:
Sleeping
Sleeping
File size: 1,460 Bytes
67ab09e d300aee 67ab09e d300aee 67ab09e d300aee 67ab09e d300aee 67ab09e d300aee 67ab09e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | """HF compute space — face age/gender/emotion over ONNX.
Called by the static demo (ingyoun/face-rec-demo) via @gradio/client on upload,
and usable directly. Detection: RetinaFace (uniface ONNX). Classifiers: the
project's own age/gender/emotion models converted to ONNX.
"""
import gradio as gr
from inference import FacePipeline, draw
pipe = FacePipeline()
def analyze(image):
if image is None:
return None, []
results = pipe.predict(image)
annotated = draw(image, results)
faces = [
{
"idx": i + 1,
"age": r["age"],
"gender": r["gender"],
"female_prob": r["female_prob"],
"emotion": r["emotion"],
}
for i, r in enumerate(results)
]
return annotated, faces
with gr.Blocks(title="Face Age·Gender·Emotion") as demo:
gr.Markdown(
"## 얼굴 나이·성별·감정 추정 (ONNX)\n"
"RetinaFace 검출 후 얼굴마다 나이(회귀)·성별·감정(6클래스)을 동시 추정합니다."
)
with gr.Row():
inp = gr.Image(type="numpy", label="입력 이미지")
out_img = gr.Image(type="numpy", label="결과")
out_json = gr.JSON(label="faces")
btn = gr.Button("분석", variant="primary")
btn.click(analyze, inputs=inp, outputs=[out_img, out_json], api_name="predict")
inp.upload(analyze, inputs=inp, outputs=[out_img, out_json])
if __name__ == "__main__":
demo.launch()
|