Zhu-FaceOnLive commited on
Commit
49371de
·
verified ·
1 Parent(s): cbec372

Update gradio/demo.py

Browse files
Files changed (1) hide show
  1. gradio/demo.py +18 -2
gradio/demo.py CHANGED
@@ -12,7 +12,23 @@ def face_liveness(frame):
12
  r = requests.post(url=url, files=files)
13
  return r.json()
14
 
15
- with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  gr.Markdown(
17
  """
18
  # Face Liveness Detection
@@ -26,7 +42,7 @@ with gr.Blocks() as demo:
26
  )
27
  with gr.Row():
28
  with gr.Column(scale=5):
29
- image_input = gr.Image(type='filepath')
30
  gr.Examples(['gradio/examples/1.jpg', 'gradio/examples/2.jpg', 'gradio/examples/3.jpg', 'gradio/examples/4.jpg'],
31
  inputs=image_input)
32
  face_liveness_button = gr.Button("Check Liveness")
 
12
  r = requests.post(url=url, files=files)
13
  return r.json()
14
 
15
+ css = """
16
+ .example-image img{
17
+ display: flex; /* Use flexbox to align items */
18
+ justify-content: center; /* Center the image horizontally */
19
+ align-items: center; /* Center the image vertically */
20
+ height: 300px; /* Set the height of the container */
21
+ object-fit: contain; /* Preserve aspect ratio while fitting the image within the container */
22
+ }
23
+ .example-image{
24
+ display: flex; /* Use flexbox to align items */
25
+ justify-content: center; /* Center the image horizontally */
26
+ align-items: center; /* Center the image vertically */
27
+ height: 350px; /* Set the height of the container */
28
+ object-fit: contain; /* Preserve aspect ratio while fitting the image within the container */
29
+ }
30
+ """
31
+ with gr.Blocks(css=css) as demo:
32
  gr.Markdown(
33
  """
34
  # Face Liveness Detection
 
42
  )
43
  with gr.Row():
44
  with gr.Column(scale=5):
45
+ image_input = gr.Image(type='filepath', elem_classes="example-image")
46
  gr.Examples(['gradio/examples/1.jpg', 'gradio/examples/2.jpg', 'gradio/examples/3.jpg', 'gradio/examples/4.jpg'],
47
  inputs=image_input)
48
  face_liveness_button = gr.Button("Check Liveness")