Spaces:
Runtime error
Runtime error
clickable labels for individual faces
Browse files
app.py
CHANGED
@@ -23,8 +23,8 @@ with gr.Blocks() as demo:
|
|
23 |
|
24 |
annotated_image = gr.AnnotatedImage()
|
25 |
|
26 |
-
jsontext = gr.Text(label= "deepface extract_faces results")
|
27 |
-
selected_face = gr.Textbox(label="Selected Face")
|
28 |
|
29 |
|
30 |
|
@@ -38,13 +38,13 @@ with gr.Blocks() as demo:
|
|
38 |
jsontext = ''
|
39 |
global faceannotations
|
40 |
faceannotations = []
|
41 |
-
for face_obj in face_objs:
|
42 |
face_coordinates = (face_obj["facial_area"]["x"],face_obj["facial_area"]["y"], (face_obj["facial_area"]["x"] + face_obj["facial_area"]["w"]),(face_obj["facial_area"]["y"] + face_obj["facial_area"]["h"]))
|
43 |
-
face_confidence = "{:.0%}".format(face_obj["confidence"])
|
44 |
face_result=[face_coordinates,face_confidence]
|
45 |
faceannotations.append(face_result)
|
46 |
|
47 |
-
jsontext=faceannotations
|
48 |
#jsontext=face_objs
|
49 |
run_time = str(round((time.time() - start_time),2))
|
50 |
results = gr.AnnotatedImage(
|
@@ -53,14 +53,14 @@ with gr.Blocks() as demo:
|
|
53 |
)
|
54 |
|
55 |
print(run_time)
|
56 |
-
return(results,
|
57 |
|
58 |
dbackendchoice = gr.Radio(choices=dbackends,label='Detector Backend:',value='retinaface')
|
59 |
gr.Interface(
|
60 |
allow_flagging = "never",
|
61 |
fn=findFaces,
|
62 |
inputs=[gr.Image(value="8428_26_SM.jpg"), dbackendchoice],
|
63 |
-
outputs=[annotated_image,
|
64 |
)
|
65 |
def select_section(evt: gr.SelectData):
|
66 |
return faceannotations[evt.index]
|
|
|
23 |
|
24 |
annotated_image = gr.AnnotatedImage()
|
25 |
|
26 |
+
#jsontext = gr.Text(label= "deepface extract_faces results")
|
27 |
+
selected_face = gr.Textbox(label="Selected Face", value="Click on a face above")
|
28 |
|
29 |
|
30 |
|
|
|
38 |
jsontext = ''
|
39 |
global faceannotations
|
40 |
faceannotations = []
|
41 |
+
for i, face_obj in enumerate(face_objs,1):
|
42 |
face_coordinates = (face_obj["facial_area"]["x"],face_obj["facial_area"]["y"], (face_obj["facial_area"]["x"] + face_obj["facial_area"]["w"]),(face_obj["facial_area"]["y"] + face_obj["facial_area"]["h"]))
|
43 |
+
face_confidence = "Face " + str(i) + ": "+ "{:.0%}".format(face_obj["confidence"])
|
44 |
face_result=[face_coordinates,face_confidence]
|
45 |
faceannotations.append(face_result)
|
46 |
|
47 |
+
#jsontext=faceannotations
|
48 |
#jsontext=face_objs
|
49 |
run_time = str(round((time.time() - start_time),2))
|
50 |
results = gr.AnnotatedImage(
|
|
|
53 |
)
|
54 |
|
55 |
print(run_time)
|
56 |
+
return(results,numberoffaces,run_time)
|
57 |
|
58 |
dbackendchoice = gr.Radio(choices=dbackends,label='Detector Backend:',value='retinaface')
|
59 |
gr.Interface(
|
60 |
allow_flagging = "never",
|
61 |
fn=findFaces,
|
62 |
inputs=[gr.Image(value="8428_26_SM.jpg"), dbackendchoice],
|
63 |
+
outputs=[annotated_image,selected_face],
|
64 |
)
|
65 |
def select_section(evt: gr.SelectData):
|
66 |
return faceannotations[evt.index]
|