Spaces:
Running
Running
omerbartal
commited on
Commit
•
ecbe199
1
Parent(s):
6e8765b
Update app.py
Browse files
app.py
CHANGED
@@ -15,25 +15,25 @@ from diffusers import StableDiffusionPanoramaPipeline, DDIMScheduler
|
|
15 |
|
16 |
model_ckpt = "stabilityai/stable-diffusion-2-base"
|
17 |
scheduler = DDIMScheduler.from_pretrained(model_ckpt, subfolder="scheduler")
|
18 |
-
# pipe = StableDiffusionPanoramaPipeline.from_pretrained(
|
19 |
-
# model_ckpt, scheduler=scheduler, torch_dtype=torch.float16
|
20 |
-
# )
|
21 |
pipe = StableDiffusionPanoramaPipeline.from_pretrained(
|
22 |
-
model_ckpt, scheduler=scheduler
|
23 |
)
|
|
|
|
|
|
|
24 |
|
25 |
pipe = pipe.to(torch.device("cuda" if torch.cuda.is_available() else "cpu"))
|
26 |
|
27 |
-
def generate_image_fn(prompt: str,
|
28 |
start_time = time.time()
|
29 |
prompt = "a photo of the dolomites"
|
30 |
-
image = pipe(prompt,
|
31 |
end_time = time.time()
|
32 |
print(f"Time taken: {end_time - start_time} seconds.")
|
33 |
return image
|
34 |
|
35 |
|
36 |
-
description = "This Space demonstrates MultiDiffusion Text2Panorama using Stable Diffusion model.
|
37 |
article = "This Space leverages a T4 GPU to run the predictions. We use mixed-precision to speed up the inference latency."
|
38 |
gr.Interface(
|
39 |
generate_image_fn,
|
@@ -43,12 +43,12 @@ gr.Interface(
|
|
43 |
max_lines=1,
|
44 |
placeholder="a photo of the dolomites",
|
45 |
),
|
46 |
-
gr.Slider(value=
|
47 |
],
|
48 |
outputs=gr.Gallery().style(grid=[2], height="auto"),
|
49 |
-
title="Generate
|
50 |
description=description,
|
51 |
article=article,
|
52 |
-
examples=[["a photo of the dolomites",
|
53 |
allow_flagging=False,
|
54 |
).launch(enable_queue=True)
|
|
|
15 |
|
16 |
model_ckpt = "stabilityai/stable-diffusion-2-base"
|
17 |
scheduler = DDIMScheduler.from_pretrained(model_ckpt, subfolder="scheduler")
|
|
|
|
|
|
|
18 |
pipe = StableDiffusionPanoramaPipeline.from_pretrained(
|
19 |
+
model_ckpt, scheduler=scheduler, torch_dtype=torch.float16
|
20 |
)
|
21 |
+
# pipe = StableDiffusionPanoramaPipeline.from_pretrained(
|
22 |
+
# model_ckpt, scheduler=scheduler
|
23 |
+
# )
|
24 |
|
25 |
pipe = pipe.to(torch.device("cuda" if torch.cuda.is_available() else "cpu"))
|
26 |
|
27 |
+
def generate_image_fn(prompt: str, img_width: int, img_height=512) -> list:
|
28 |
start_time = time.time()
|
29 |
prompt = "a photo of the dolomites"
|
30 |
+
image = pipe(prompt, height=img_height, width=img_width).images
|
31 |
end_time = time.time()
|
32 |
print(f"Time taken: {end_time - start_time} seconds.")
|
33 |
return image
|
34 |
|
35 |
|
36 |
+
description = "This Space demonstrates MultiDiffusion Text2Panorama using Stable Diffusion model. To get started, either enter a prompt and pick one from the examples below. For details, please visit [the project page](https://multidiffusion.github.io/)."
|
37 |
article = "This Space leverages a T4 GPU to run the predictions. We use mixed-precision to speed up the inference latency."
|
38 |
gr.Interface(
|
39 |
generate_image_fn,
|
|
|
43 |
max_lines=1,
|
44 |
placeholder="a photo of the dolomites",
|
45 |
),
|
46 |
+
gr.Slider(value=4096, minimum=512, maximum=4608, step=128),
|
47 |
],
|
48 |
outputs=gr.Gallery().style(grid=[2], height="auto"),
|
49 |
+
title="Generate a panoramic image!",
|
50 |
description=description,
|
51 |
article=article,
|
52 |
+
examples=[["a photo of the dolomites", 4096]],
|
53 |
allow_flagging=False,
|
54 |
).launch(enable_queue=True)
|