Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -240,7 +240,7 @@ def add_metadata_to_image(image, metadata):
|
|
240 |
return Image.open(buffer)
|
241 |
|
242 |
if not torch.cuda.is_available():
|
243 |
-
DESCRIPTION
|
244 |
|
245 |
MAX_SEED = np.iinfo(np.int32).max
|
246 |
MAX_IMAGE_SIZE = 2048
|
@@ -291,12 +291,16 @@ def infer(
|
|
291 |
requires_pooled=[False, True],
|
292 |
truncate_long_prompts=False
|
293 |
)
|
|
|
|
|
|
|
294 |
# 在 infer 函数中调用 get_embed_new
|
295 |
if not use_negative_prompt:
|
296 |
negative_prompt = ""
|
297 |
-
|
298 |
-
|
299 |
-
|
|
|
300 |
|
301 |
# 在调用 pipe 时,使用新的参数名称(确保参数名称正确)
|
302 |
image = pipe(
|
@@ -311,11 +315,12 @@ def infer(
|
|
311 |
generator=generator,
|
312 |
use_resolution_binning=use_resolution_binning,
|
313 |
).images[0]
|
|
|
314 |
# Create metadata dictionary
|
315 |
metadata = {
|
316 |
-
"prompt":
|
317 |
-
"processed_prompt":
|
318 |
-
"negative_prompt": negative_prompt,
|
319 |
"seed": seed,
|
320 |
"width": width,
|
321 |
"height": height,
|
|
|
240 |
return Image.open(buffer)
|
241 |
|
242 |
if not torch.cuda.is_available():
|
243 |
+
DESCRIPTION = "\n<p>你现在运行在CPU上 但是此项目只支持GPU.</p>"
|
244 |
|
245 |
MAX_SEED = np.iinfo(np.int32).max
|
246 |
MAX_IMAGE_SIZE = 2048
|
|
|
291 |
requires_pooled=[False, True],
|
292 |
truncate_long_prompts=False
|
293 |
)
|
294 |
+
# Store the original prompt before processing
|
295 |
+
original_prompt_text = prompt
|
296 |
+
|
297 |
# 在 infer 函数中调用 get_embed_new
|
298 |
if not use_negative_prompt:
|
299 |
negative_prompt = ""
|
300 |
+
|
301 |
+
processed_prompt = get_embed_new(prompt, pipe, compel, only_convert_string=True)
|
302 |
+
processed_negative_prompt = get_embed_new(negative_prompt, pipe, compel, only_convert_string=True)
|
303 |
+
conditioning, pooled = compel([processed_prompt, processed_negative_prompt]) # 必须同时处理来保证长度相等
|
304 |
|
305 |
# 在调用 pipe 时,使用新的参数名称(确保参数名称正确)
|
306 |
image = pipe(
|
|
|
315 |
generator=generator,
|
316 |
use_resolution_binning=use_resolution_binning,
|
317 |
).images[0]
|
318 |
+
|
319 |
# Create metadata dictionary
|
320 |
metadata = {
|
321 |
+
"prompt": original_prompt_text,
|
322 |
+
"processed_prompt": processed_prompt,
|
323 |
+
"negative_prompt": negative_prompt if use_negative_prompt else "",
|
324 |
"seed": seed,
|
325 |
"width": width,
|
326 |
"height": height,
|