Spaces:
Running
on
Zero
Running
on
Zero
Yuxuan Zhang
commited on
Commit
·
152c7d3
1
Parent(s):
9d3dabd
num image
Browse files
app.py
CHANGED
|
@@ -112,21 +112,23 @@ threading.Thread(target=delete_old_files, daemon=True).start()
|
|
| 112 |
|
| 113 |
|
| 114 |
@spaces.GPU(duration=180) # [uncomment to use ZeroGPU]
|
| 115 |
-
def infer(prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,
|
| 116 |
progress=gr.Progress(track_tqdm=True)):
|
| 117 |
if randomize_seed:
|
| 118 |
seed = random.randint(0, 65536)
|
| 119 |
|
| 120 |
-
|
| 121 |
prompt=prompt,
|
| 122 |
guidance_scale=guidance_scale,
|
| 123 |
-
num_images_per_prompt=
|
| 124 |
num_inference_steps=num_inference_steps,
|
| 125 |
width=width,
|
| 126 |
height=height,
|
| 127 |
generator=torch.Generator().manual_seed(seed)
|
| 128 |
-
).images
|
| 129 |
-
|
|
|
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
examples = [
|
|
@@ -247,7 +249,7 @@ with gr.Blocks() as demo:
|
|
| 247 |
scale=3
|
| 248 |
)
|
| 249 |
ex_img = gr.Image(
|
| 250 |
-
value=f"
|
| 251 |
label="Effect",
|
| 252 |
interactive=False,
|
| 253 |
height=130,
|
|
|
|
| 112 |
|
| 113 |
|
| 114 |
@spaces.GPU(duration=180) # [uncomment to use ZeroGPU]
|
| 115 |
+
def infer(prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, num_images,
|
| 116 |
progress=gr.Progress(track_tqdm=True)):
|
| 117 |
if randomize_seed:
|
| 118 |
seed = random.randint(0, 65536)
|
| 119 |
|
| 120 |
+
images = pipe(
|
| 121 |
prompt=prompt,
|
| 122 |
guidance_scale=guidance_scale,
|
| 123 |
+
num_images_per_prompt=num_images, # 生成 num_images 张图
|
| 124 |
num_inference_steps=num_inference_steps,
|
| 125 |
width=width,
|
| 126 |
height=height,
|
| 127 |
generator=torch.Generator().manual_seed(seed)
|
| 128 |
+
).images # 获取生成的图片列表
|
| 129 |
+
|
| 130 |
+
return images, seed
|
| 131 |
+
|
| 132 |
|
| 133 |
|
| 134 |
examples = [
|
|
|
|
| 249 |
scale=3
|
| 250 |
)
|
| 251 |
ex_img = gr.Image(
|
| 252 |
+
value=f"img/img_{i + 1}.png",
|
| 253 |
label="Effect",
|
| 254 |
interactive=False,
|
| 255 |
height=130,
|