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

test compile pipe

Browse files
Files changed (1) hide show
  1. app_onediff.py +5 -19
app_onediff.py CHANGED
@@ -60,6 +60,7 @@ base_pipe = AutoPipelineForText2Image.from_pretrained(
60
  base_pipe.to(device)
61
 
62
  # base_pipe = nexfort_compile(base_pipe)
 
63
 
64
  from gfpgan.utils import GFPGANer
65
  from basicsr.archs.srvgg_arch import SRVGGNetCompact
@@ -79,23 +80,6 @@ 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=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,
@@ -104,7 +88,9 @@ def create_demo() -> gr.Blocks:
104
  run_task_time = 0
105
  time_cost_str = ''
106
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
107
- generated_image = base_pipe(
 
 
108
  prompt=prompt,
109
  num_inference_steps=steps,
110
  ).images[0]
@@ -139,7 +125,7 @@ def create_demo() -> gr.Blocks:
139
  g_btn.click(
140
  fn=compile_pipe,
141
  inputs=[prompt, steps],
142
- outputs=[time_cost],
143
  )
144
 
145
  return demo
 
60
  base_pipe.to(device)
61
 
62
  # base_pipe = nexfort_compile(base_pipe)
63
+ compiled_pipe = None
64
 
65
  from gfpgan.utils import GFPGANer
66
  from basicsr.archs.srvgg_arch import SRVGGNetCompact
 
80
 
81
  def create_demo() -> gr.Blocks:
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  @spaces.GPU(duration=30)
84
  def text_to_image(
85
  prompt:str,
 
88
  run_task_time = 0
89
  time_cost_str = ''
90
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
91
+ if compiled_pipe is None:
92
+ compiled_pipe = nexfort_compile(base_pipe)
93
+ generated_image = compiled_pipe(
94
  prompt=prompt,
95
  num_inference_steps=steps,
96
  ).images[0]
 
125
  g_btn.click(
126
  fn=compile_pipe,
127
  inputs=[prompt, steps],
128
+ outputs=[generated_image, time_cost],
129
  )
130
 
131
  return demo