Siyun He commited on
Commit
52be6f8
Β·
1 Parent(s): 92727b3

improve gradio interface

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -205,18 +205,21 @@ def webcam_input(frame, transform):
205
  return frame, face_shape, glass_shape
206
 
207
  # Gradio Interface
208
- with gr.Blocks() as demo:
 
209
  with gr.Column(elem_classes=["my-column"]):
210
  with gr.Group(elem_classes=["my-group"]):
211
  transform = gr.Dropdown(choices=["cartoon", "edges", "sepia", "negative", "sketch", "blur", "none"],
212
- value="none", label="Transformation")
 
213
  input_img = gr.Image(sources=["webcam"], type="numpy", streaming=True)
 
214
  face_shape_output = gr.Textbox(label="Detected Face Shape")
215
  glass_shape_output = gr.Textbox(label="Recommended Glass Shape")
216
- next_button = gr.Button("Next Glasses")
217
- save_button = gr.Button("Save as a Picture")
218
 
219
- input_img.stream(webcam_input, [input_img, transform], [input_img, face_shape_output, glass_shape_output], time_limit=30, stream_every=0.1)
220
  with gr.Row():
221
  next_button.click(change_glasses, [], [])
222
  with gr.Row():
@@ -224,6 +227,3 @@ with gr.Blocks() as demo:
224
 
225
  if __name__ == "__main__":
226
  demo.launch(share=True)
227
-
228
-
229
-
 
205
  return frame, face_shape, glass_shape
206
 
207
  # Gradio Interface
208
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple", secondary_hue="blue")) as demo:
209
+ gr.Markdown("<h1 style='text-align: center; font-weight: bold;'>πŸ€“ Glasses Virtual Try-On πŸ•ΆοΈπŸ‘“</h1>")
210
  with gr.Column(elem_classes=["my-column"]):
211
  with gr.Group(elem_classes=["my-group"]):
212
  transform = gr.Dropdown(choices=["cartoon", "edges", "sepia", "negative", "sketch", "blur", "none"],
213
+ value="none", label="Select Filter")
214
+ gr.Markdown("Click the Webcam icon to start the camera, and then press the record button to start the virtual try-on.")
215
  input_img = gr.Image(sources=["webcam"], type="numpy", streaming=True)
216
+ gr.Markdown("Face Shape and Recommended Glass Shape")
217
  face_shape_output = gr.Textbox(label="Detected Face Shape")
218
  glass_shape_output = gr.Textbox(label="Recommended Glass Shape")
219
+ next_button = gr.Button("Next Glasses➑️")
220
+ save_button = gr.Button("Save as a PictureπŸ“Œ")
221
 
222
+ input_img.stream(webcam_input, [input_img, transform], [input_img, face_shape_output, glass_shape_output], stream_every=0.1)
223
  with gr.Row():
224
  next_button.click(change_glasses, [], [])
225
  with gr.Row():
 
227
 
228
  if __name__ == "__main__":
229
  demo.launch(share=True)