Yuliang commited on
Commit
a5aeba8
1 Parent(s): a3f1f2c

cached_exmaple=False

Browse files
Files changed (1) hide show
  1. app.py +19 -11
app.py CHANGED
@@ -3,7 +3,8 @@
3
 
4
  import glob
5
  import gradio as gr
6
- import os, random
 
7
 
8
  import subprocess
9
 
@@ -70,13 +71,15 @@ def generate_image(seed, psi):
70
  img = iface(seed, psi)
71
  return img
72
 
 
73
  random.seed(1993)
74
  model_types = ['icon-filter', 'pifu', 'pamir']
75
- examples = [[item, random.choice(model_types)] for item in random.sample(sorted(glob.glob('examples/*.png')), 4)]
 
76
 
77
  with gr.Blocks() as demo:
78
  gr.Markdown(description)
79
-
80
  out_lst = []
81
  with gr.Row():
82
  with gr.Column():
@@ -86,7 +89,8 @@ with gr.Blocks() as demo:
86
  0, 100, step=1, default=0, label='Seed (For Image Generation)')
87
  psi = gr.inputs.Slider(
88
  0, 2, step=0.05, default=0.7, label='Truncation psi (For Image Generation)')
89
- radio_choice = gr.Radio(model_types, label='Method (For Reconstruction)', value='icon-filter')
 
90
  inp = gr.Image(type="filepath", label="Input Image")
91
  with gr.Row():
92
  btn_sample = gr.Button("Sample Image")
@@ -94,29 +98,33 @@ with gr.Blocks() as demo:
94
 
95
  gr.Examples(examples=examples,
96
  inputs=[inp, radio_choice],
97
- cache_examples=True,
98
  fn=generate_model,
99
  outputs=out_lst)
100
 
101
- out_vid_download = gr.File(label="Download Video, welcome share on Twitter with #ICON")
 
102
 
103
  with gr.Column():
104
- overlap_inp = gr.Image(type="filepath", label="Image Normal Overlap")
 
105
  out_smpl = gr.Model3D(
106
  clear_color=[0.0, 0.0, 0.0, 0.0], label="SMPL")
107
  out_smpl_download = gr.File(label="Download SMPL mesh")
108
  out_smpl_npy_download = gr.File(label="Download SMPL params")
109
  out_recon = gr.Model3D(
110
- clear_color=[0.0, 0.0, 0.0, 0.0], label="ICON")
111
  out_recon_download = gr.File(label="Download clothed human mesh")
112
  out_final = gr.Model3D(
113
- clear_color=[0.0, 0.0, 0.0, 0.0], label="ICON++")
114
- out_final_download = gr.File(label="Download refined clothed human mesh")
 
115
 
116
  out_lst = [out_smpl, out_smpl_download, out_smpl_npy_download, out_recon, out_recon_download,
117
  out_final, out_final_download, out_vid_download, overlap_inp]
118
 
119
- btn_submit.click(fn=generate_model, inputs=[inp, radio_choice], outputs=out_lst)
 
120
  btn_sample.click(fn=generate_image, inputs=[seed, psi], outputs=inp)
121
 
122
  if __name__ == "__main__":
 
3
 
4
  import glob
5
  import gradio as gr
6
+ import os
7
+ import random
8
 
9
  import subprocess
10
 
 
71
  img = iface(seed, psi)
72
  return img
73
 
74
+
75
  random.seed(1993)
76
  model_types = ['icon-filter', 'pifu', 'pamir']
77
+ examples = [[item, random.choice(model_types)] for item in random.sample(
78
+ sorted(glob.glob('examples/*.png')), 8)]
79
 
80
  with gr.Blocks() as demo:
81
  gr.Markdown(description)
82
+
83
  out_lst = []
84
  with gr.Row():
85
  with gr.Column():
 
89
  0, 100, step=1, default=0, label='Seed (For Image Generation)')
90
  psi = gr.inputs.Slider(
91
  0, 2, step=0.05, default=0.7, label='Truncation psi (For Image Generation)')
92
+ radio_choice = gr.Radio(
93
+ model_types, label='Method (For Reconstruction)', value='icon-filter')
94
  inp = gr.Image(type="filepath", label="Input Image")
95
  with gr.Row():
96
  btn_sample = gr.Button("Sample Image")
 
98
 
99
  gr.Examples(examples=examples,
100
  inputs=[inp, radio_choice],
101
+ cache_examples=False,
102
  fn=generate_model,
103
  outputs=out_lst)
104
 
105
+ out_vid_download = gr.File(
106
+ label="Download Video, welcome share on Twitter with #ICON")
107
 
108
  with gr.Column():
109
+ overlap_inp = gr.Image(
110
+ type="filepath", label="Image Normal Overlap")
111
  out_smpl = gr.Model3D(
112
  clear_color=[0.0, 0.0, 0.0, 0.0], label="SMPL")
113
  out_smpl_download = gr.File(label="Download SMPL mesh")
114
  out_smpl_npy_download = gr.File(label="Download SMPL params")
115
  out_recon = gr.Model3D(
116
+ clear_color=[0.0, 0.0, 0.0, 0.0], label="Recon")
117
  out_recon_download = gr.File(label="Download clothed human mesh")
118
  out_final = gr.Model3D(
119
+ clear_color=[0.0, 0.0, 0.0, 0.0], label="Refined Recon")
120
+ out_final_download = gr.File(
121
+ label="Download refined clothed human mesh")
122
 
123
  out_lst = [out_smpl, out_smpl_download, out_smpl_npy_download, out_recon, out_recon_download,
124
  out_final, out_final_download, out_vid_download, overlap_inp]
125
 
126
+ btn_submit.click(fn=generate_model, inputs=[
127
+ inp, radio_choice], outputs=out_lst)
128
  btn_sample.click(fn=generate_image, inputs=[seed, psi], outputs=inp)
129
 
130
  if __name__ == "__main__":