Vincentqyw commited on
Commit
13ccdc7
·
1 Parent(s): 4b7a504

update: app

Browse files
Files changed (1) hide show
  1. app.py +23 -10
app.py CHANGED
@@ -26,6 +26,14 @@ def process(input_list, quality=80):
26
  return out_files, out_images
27
 
28
 
 
 
 
 
 
 
 
 
29
  def run(server_name="127.0.0.1", server_port=7860):
30
  with gr.Blocks() as app:
31
  gr.Markdown(
@@ -38,16 +46,15 @@ def run(server_name="127.0.0.1", server_port=7860):
38
 
39
  with gr.Row(equal_height=False):
40
  with gr.Column():
 
 
 
 
 
 
 
41
  inputs = [
42
- gr.Gallery(
43
- label="Input images",
44
- show_label=True,
45
- elem_id="gallery",
46
- object_fit="contain",
47
- height="auto",
48
- columns=4,
49
- # min_width=100,
50
- ),
51
  gr.Slider(
52
  minimum=1,
53
  maximum=100,
@@ -68,10 +75,16 @@ def run(server_name="127.0.0.1", server_port=7860):
68
  object_fit="contain",
69
  height="auto",
70
  columns=4,
 
71
  ),
72
  ]
73
-
 
 
 
 
74
  btn.click(process, inputs=inputs, outputs=outputs)
 
75
  app.queue().launch(
76
  server_name=server_name, server_port=server_port, share=False
77
  )
 
26
  return out_files, out_images
27
 
28
 
29
+ def swap_to_gallery(images):
30
+ return (
31
+ gr.update(value=images, visible=True),
32
+ gr.update(visible=True),
33
+ gr.update(visible=False),
34
+ )
35
+
36
+
37
  def run(server_name="127.0.0.1", server_port=7860):
38
  with gr.Blocks() as app:
39
  gr.Markdown(
 
46
 
47
  with gr.Row(equal_height=False):
48
  with gr.Column():
49
+ files = gr.Files(
50
+ label="Drag 1 or more photos of your face",
51
+ file_types=["image"],
52
+ )
53
+ uploaded_files = gr.Gallery(
54
+ label="Your images", visible=False, columns=4, height=250
55
+ )
56
  inputs = [
57
+ uploaded_files,
 
 
 
 
 
 
 
 
58
  gr.Slider(
59
  minimum=1,
60
  maximum=100,
 
75
  object_fit="contain",
76
  height="auto",
77
  columns=4,
78
+ # height=125,
79
  ),
80
  ]
81
+ files.upload(
82
+ fn=swap_to_gallery,
83
+ inputs=files,
84
+ outputs=[uploaded_files, btn, files],
85
+ )
86
  btn.click(process, inputs=inputs, outputs=outputs)
87
+ #
88
  app.queue().launch(
89
  server_name=server_name, server_port=server_port, share=False
90
  )