zhiweili commited on
Commit
ff41721
Β·
1 Parent(s): b249299

test compile pipe

Browse files
Files changed (1) hide show
  1. app_onediff.py +20 -3
app_onediff.py CHANGED
@@ -37,7 +37,7 @@ os.system("pip show nexfort")
37
  os.system("pip show onediff")
38
  os.system("pip show onediffx")
39
 
40
- from onediffx import compile_pipe
41
 
42
  def nexfort_compile(torch_module: torch.nn.Module):
43
  options = json.loads('{"mode": "max-autotune:cudagraphs", "dynamic": true}')
@@ -79,6 +79,23 @@ face_enhancer = GFPGANer(model_path='GFPGANv1.4.pth', upscale=2, arch='clean', c
79
 
80
  def create_demo() -> gr.Blocks:
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  @spaces.GPU(duration=30)
83
  def text_to_image(
84
  prompt:str,
@@ -120,9 +137,9 @@ def create_demo() -> gr.Blocks:
120
  time_cost = gr.Textbox(label="Time Cost", lines=1, interactive=False)
121
 
122
  g_btn.click(
123
- fn=text_to_image,
124
  inputs=[prompt, steps],
125
- outputs=[generated_image, time_cost],
126
  )
127
 
128
  return demo
 
37
  os.system("pip show onediff")
38
  os.system("pip show onediffx")
39
 
40
+ from onediffx import compile_pipe, save_pipe
41
 
42
  def nexfort_compile(torch_module: torch.nn.Module):
43
  options = json.loads('{"mode": "max-autotune:cudagraphs", "dynamic": true}')
 
79
 
80
  def create_demo() -> gr.Blocks:
81
 
82
+ @spaces.GPU(duration=120)
83
+ def compile_pipe(
84
+ prompt:str,
85
+ steps:int,
86
+ ):
87
+ run_task_time = 0
88
+ time_cost_str = ''
89
+ run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
90
+ compiled_pipe = nexfort_compile(base_pipe)
91
+ run_task_time = 0
92
+ time_cost_str = ''
93
+ run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
94
+ if not os.path.exists('cache_pipe'):
95
+ os.makedirs('cached_pipe')
96
+ save_pipe(compiled_pipe, dir="cached_pipe")
97
+ return time_cost_str
98
+
99
  @spaces.GPU(duration=30)
100
  def text_to_image(
101
  prompt:str,
 
137
  time_cost = gr.Textbox(label="Time Cost", lines=1, interactive=False)
138
 
139
  g_btn.click(
140
+ fn=compile_pipe,
141
  inputs=[prompt, steps],
142
+ outputs=[time_cost],
143
  )
144
 
145
  return demo