Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -162,12 +162,32 @@ def update_dimensions_from_image(image_list):
|
|
| 162 |
|
| 163 |
return new_width, new_height
|
| 164 |
|
| 165 |
-
# ⚠️ spaces.GPU
|
| 166 |
-
#
|
| 167 |
-
# progress 파라미터는 기본값 없이 사용 (gr.Progress와 @spaces.GPU 충돌 방지)
|
| 168 |
@spaces.GPU
|
| 169 |
-
def generate_image(
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
generator = torch.Generator(device=device).manual_seed(seed)
|
| 173 |
|
|
@@ -214,17 +234,19 @@ def infer(prompt, input_images=None, seed=42, randomize_seed=False, width=1024,
|
|
| 214 |
prompt_embeds = remote_text_encoder(final_prompt)
|
| 215 |
|
| 216 |
progress(0.3, desc="Waiting for GPU...")
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
| 228 |
|
| 229 |
# 정보 로그 생성
|
| 230 |
info_log = f"""✅ GENERATION COMPLETE!
|
|
|
|
| 162 |
|
| 163 |
return new_width, new_height
|
| 164 |
|
| 165 |
+
# ⚠️ spaces.GPU 데코레이터는 파라미터 개수 제한이 있음
|
| 166 |
+
# 모든 파라미터를 하나의 dict로 묶어서 전달
|
|
|
|
| 167 |
@spaces.GPU
|
| 168 |
+
def generate_image(generation_args):
|
| 169 |
+
"""
|
| 170 |
+
generation_args = {
|
| 171 |
+
'prompt_embeds': tensor,
|
| 172 |
+
'image_list': list or None,
|
| 173 |
+
'width': int,
|
| 174 |
+
'height': int,
|
| 175 |
+
'num_inference_steps': int,
|
| 176 |
+
'guidance_scale': float,
|
| 177 |
+
'seed': int,
|
| 178 |
+
'use_turbo': bool,
|
| 179 |
+
'progress': gr.Progress or None
|
| 180 |
+
}
|
| 181 |
+
"""
|
| 182 |
+
prompt_embeds = generation_args['prompt_embeds'].to(device)
|
| 183 |
+
image_list = generation_args.get('image_list')
|
| 184 |
+
width = generation_args['width']
|
| 185 |
+
height = generation_args['height']
|
| 186 |
+
num_inference_steps = generation_args['num_inference_steps']
|
| 187 |
+
guidance_scale = generation_args['guidance_scale']
|
| 188 |
+
seed = generation_args['seed']
|
| 189 |
+
use_turbo = generation_args['use_turbo']
|
| 190 |
+
progress = generation_args.get('progress')
|
| 191 |
|
| 192 |
generator = torch.Generator(device=device).manual_seed(seed)
|
| 193 |
|
|
|
|
| 234 |
prompt_embeds = remote_text_encoder(final_prompt)
|
| 235 |
|
| 236 |
progress(0.3, desc="Waiting for GPU...")
|
| 237 |
+
# generate_image에 dict로 전달
|
| 238 |
+
generation_args = {
|
| 239 |
+
'prompt_embeds': prompt_embeds,
|
| 240 |
+
'image_list': image_list,
|
| 241 |
+
'width': width,
|
| 242 |
+
'height': height,
|
| 243 |
+
'num_inference_steps': num_inference_steps,
|
| 244 |
+
'guidance_scale': guidance_scale,
|
| 245 |
+
'seed': seed,
|
| 246 |
+
'use_turbo': use_turbo,
|
| 247 |
+
'progress': progress
|
| 248 |
+
}
|
| 249 |
+
image = generate_image(generation_args)
|
| 250 |
|
| 251 |
# 정보 로그 생성
|
| 252 |
info_log = f"""✅ GENERATION COMPLETE!
|