pleonard commited on
Commit
7beb285
·
1 Parent(s): a9b01d5

pull out individual faces

Browse files
Files changed (3) hide show
  1. .gitignore +1 -4
  2. __pycache__/app.cpython-38.pyc +0 -0
  3. app.py +11 -7
.gitignore CHANGED
@@ -1,5 +1,2 @@
1
 
2
- /__pycache__
3
- /__pycache__
4
- /__pycache__
5
- /__pycache__
 
1
 
2
+ __pycache__
 
 
 
__pycache__/app.cpython-38.pyc CHANGED
Binary files a/__pycache__/app.cpython-38.pyc and b/__pycache__/app.cpython-38.pyc differ
 
app.py CHANGED
@@ -20,11 +20,12 @@ dbackends = [
20
 
21
  with gr.Blocks() as demo:
22
 
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
 
@@ -53,19 +54,22 @@ with gr.Blocks() as demo:
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]
 
 
 
67
 
68
- annotated_image.select(select_section, None, selected_face)
69
 
70
  demo.launch(show_error=True)
71
 
 
20
 
21
  with gr.Blocks() as demo:
22
 
23
+ input_image = gr.Image(value="8428_26_SM.jpg")
24
  annotated_image = gr.AnnotatedImage()
25
 
26
  #jsontext = gr.Text(label= "deepface extract_faces results")
27
+ selected_face_info = gr.Textbox(label="Selected Face Info", value="Click on a face above")
28
+ selected_face_pic = gr.Image(label="Selected Face", value="Click on a face above")
29
 
30
 
31
 
 
54
  )
55
 
56
  print(run_time)
57
+ return(results,numberoffaces,run_time,)
58
 
59
  dbackendchoice = gr.Radio(choices=dbackends,label='Detector Backend:',value='retinaface')
60
  gr.Interface(
61
  allow_flagging = "never",
62
  fn=findFaces,
63
+ inputs=[input_image, dbackendchoice],
64
+ outputs=[annotated_image,selected_face_info,selected_face_pic],
65
  )
66
  def select_section(evt: gr.SelectData):
67
+ cropped_image = np.array(Image.open(input_image.value['path']))
68
+ cropped_image = cropped_image[faceannotations[evt.index][0][1]:faceannotations[evt.index][0][3], faceannotations[evt.index][0][0]:faceannotations[evt.index][0][2]]
69
+ return faceannotations[evt.index], cropped_image
70
+
71
 
72
+ annotated_image.select(select_section, None, [selected_face_info,selected_face_pic])
73
 
74
  demo.launch(show_error=True)
75