federico commited on
Commit
d2d8f6c
β€’
1 Parent(s): e3b9c99

added possibilities of upload pictures

Browse files
Files changed (1) hide show
  1. app.py +23 -5
app.py CHANGED
@@ -93,16 +93,34 @@ def demo_play(img, laeo=True, rgb=False):
93
  return img
94
 
95
 
96
- demo = gr.Interface(
97
  fn=demo_play,
98
- inputs=[gr.Image(source="webcam"),
99
  gr.Checkbox(value=True, label="LAEO", info="Compute and display LAEO"),
100
- gr.Checkbox(value=True, label="rgb", info="Display output on W/B image"),
101
  ],
102
  outputs="image",
103
- live=True
 
 
 
104
  )
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  if __name__=='__main__':
107
  if not os.path.exists("LAEO_demo_data"):
108
  gdown.download_folder("https://drive.google.com/drive/folders/1nQ1Cb_tBEhWxy183t-mIcVH7AhAfa6NO?usp=drive_link",
@@ -118,4 +136,4 @@ if __name__=='__main__':
118
 
119
  print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
120
 
121
- demo.launch()
 
93
  return img
94
 
95
 
96
+ demo_webcam = gr.Interface(
97
  fn=demo_play,
98
+ inputs=[gr.Image(source="webcam"), # with no streaming-> acquire images
99
  gr.Checkbox(value=True, label="LAEO", info="Compute and display LAEO"),
100
+ gr.Checkbox(value=False, label="rgb", info="Display output on W/B image"),
101
  ],
102
  outputs="image",
103
+ live=True,
104
+ title="Head Pose Estimation and LAEO",
105
+ description="This is a demo developed by Federico Figari T. at MaLGa Lab, University of Genoa, Italy. You can choose to have only the Head Pose Estimation or also the LAEO computation (more than 1 person should be in the image). You need to take a picture and the algorithm will calculate the Head Pose and will be showed as an arrow on your face. LAEO, instead is showed colouring the arrow in green.",
106
+ # examples=EXAMPLES,
107
  )
108
 
109
+ demo_upload = gr.Interface(
110
+ fn=demo_play,
111
+ inputs=[gr.Image(source="upload",), # with no streaming-> acquire images
112
+ gr.Checkbox(value=True, label="LAEO", info="Compute and display LAEO"),
113
+ gr.Checkbox(value=False, label="rgb", info="Display output on W/B image"),
114
+ ],
115
+ outputs="image",
116
+ live=True,
117
+ title="Head Pose Estimation and LAEO",
118
+ description="This is a demo developed by Federico Figari T. at MaLGa Lab, University of Genoa, Italy. You can choose to have only the Head Pose Estimation or also the LAEO computation (more than 1 person should be in the image). You need to upload an image and the algorithm will calculate the Head Pose and will be showed as an arrow on your face. LAEO, instead is showed colouring the arrow in green.",
119
+ examples=[["/LAEO_demo_data/examples/1.jpg"], ["/LAEO_demo_data/examples/20.jpg"]]
120
+ )
121
+
122
+ demo_tabbed = gr.TabbedInterface([demo_webcam, demo_upload], ["Demo from webcam", "Demo from upload"])
123
+
124
  if __name__=='__main__':
125
  if not os.path.exists("LAEO_demo_data"):
126
  gdown.download_folder("https://drive.google.com/drive/folders/1nQ1Cb_tBEhWxy183t-mIcVH7AhAfa6NO?usp=drive_link",
 
136
 
137
  print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
138
 
139
+ demo_tabbed.launch()