Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,8 +9,10 @@ app.prepare(ctx_id=0, det_size=(640, 640))
|
|
9 |
def calculate(photo):
|
10 |
image = cv2.imread(photo)
|
11 |
faces = app.get(image)
|
|
|
12 |
faceid_embeds = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)
|
13 |
-
|
|
|
14 |
|
15 |
with gr.Blocks() as demo:
|
16 |
with gr.Row():
|
@@ -18,9 +20,10 @@ with gr.Blocks() as demo:
|
|
18 |
face_photo = gr.Image(label="Photo", type="filepath")
|
19 |
greet_btn = gr.Button("Calculate")
|
20 |
with gr.Column():
|
|
|
21 |
output = gr.JSON()
|
22 |
|
23 |
-
greet_btn.click(fn=calculate, inputs=face_photo, outputs=
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
demo.launch()
|
|
|
9 |
def calculate(photo):
|
10 |
image = cv2.imread(photo)
|
11 |
faces = app.get(image)
|
12 |
+
image_draw = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
13 |
faceid_embeds = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)
|
14 |
+
image_draw = app.draw_on(image_draw, faces)
|
15 |
+
return image_draw
|
16 |
|
17 |
with gr.Blocks() as demo:
|
18 |
with gr.Row():
|
|
|
20 |
face_photo = gr.Image(label="Photo", type="filepath")
|
21 |
greet_btn = gr.Button("Calculate")
|
22 |
with gr.Column():
|
23 |
+
output_image = gr.Image(label="Output")
|
24 |
output = gr.JSON()
|
25 |
|
26 |
+
greet_btn.click(fn=calculate, inputs=face_photo, outputs=output_image, api_name="calculate_face_embedding")
|
27 |
|
28 |
if __name__ == "__main__":
|
29 |
demo.launch()
|