Spaces:
Runtime error
Runtime error
osanseviero
commited on
Commit
•
7854755
1
Parent(s):
e6731ac
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import LatentDiffusionUncondPipeline
|
2 |
+
import torch
|
3 |
+
import PIL.Image
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
pipeline = LatentDiffusionUncondPipeline.from_pretrained("CompVis/latent-diffusion-celeba-256")
|
7 |
+
|
8 |
+
|
9 |
+
def predict(seed):
|
10 |
+
torch.manual_seed(seed)
|
11 |
+
image = pipeline(generator=generator, num_inference_steps=1)["sample"]
|
12 |
+
image_processed = image.cpu().permute(0, 2, 3, 1)
|
13 |
+
image_processed = (image_processed + 1.0) * 127.5
|
14 |
+
image_processed = image_processed.clamp(0, 255).numpy().astype(np.uint8)
|
15 |
+
return PIL.Image.fromarray(image_processed[0])
|
16 |
+
|
17 |
+
gr.Interface(
|
18 |
+
predict,
|
19 |
+
inputs=[
|
20 |
+
gr.inputs.Slider(0, 1000, label='Seed', default=42),
|
21 |
+
],
|
22 |
+
outputs="image",
|
23 |
+
).launch()
|