Spaces:
Sleeping
Sleeping
Commit
·
06f915b
1
Parent(s):
33d25b3
debug 13
Browse files
app.py
CHANGED
@@ -1,40 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
from diffusers import DiffusionPipeline
|
3 |
-
import torch
|
4 |
-
from diffusers import DDPMScheduler, UNet2DModel
|
5 |
-
from PIL import Image
|
6 |
-
import numpy as np
|
7 |
-
|
8 |
-
|
9 |
-
def erzeuge(prompt):
|
10 |
-
return pipeline(prompt).images # [0]
|
11 |
-
|
12 |
-
|
13 |
-
# def erzeuge_komplex(prompt):
|
14 |
-
# scheduler = DDPMScheduler.from_pretrained("google/ddpm-cat-256")
|
15 |
-
# model = UNet2DModel.from_pretrained("google/ddpm-cat-256").to("cuda")
|
16 |
-
# scheduler.set_timesteps(50)
|
17 |
-
|
18 |
-
# sample_size = model.config.sample_size
|
19 |
-
# noise = torch.randn((1, 3, sample_size, sample_size)).to("cuda")
|
20 |
-
# input = noise
|
21 |
-
|
22 |
-
# for t in scheduler.timesteps:
|
23 |
-
# with torch.no_grad():
|
24 |
-
# noisy_residual = model(input, t).sample
|
25 |
-
# prev_noisy_sample = scheduler.step(noisy_residual, t, input).prev_sample
|
26 |
-
# input = prev_noisy_sample
|
27 |
-
|
28 |
-
# image = (input / 2 + 0.5).clamp(0, 1)
|
29 |
-
# image = image.cpu().permute(0, 2, 3, 1).numpy()[0]
|
30 |
-
# image = Image.fromarray((image * 255).round().astype("uint8"))
|
31 |
-
# return image
|
32 |
-
|
33 |
|
34 |
# pipeline = DiffusionPipeline.from_pretrained("google/ddpm-cat-256")
|
35 |
pipeline = DiffusionPipeline.from_pretrained("google/ddpm-celebahq-256")
|
36 |
# pipeline.to("cuda")
|
37 |
|
|
|
|
|
|
|
38 |
|
39 |
with gr.Blocks() as demo:
|
40 |
with gr.Column(variant="panel"):
|
@@ -43,7 +20,7 @@ with gr.Blocks() as demo:
|
|
43 |
label="Deine Beschreibung:",
|
44 |
show_label=False,
|
45 |
max_lines=1,
|
46 |
-
placeholder="
|
47 |
)
|
48 |
btn = gr.Button("erzeuge Bild")
|
49 |
|
|
|
1 |
import gradio as gr
|
2 |
from diffusers import DiffusionPipeline
|
3 |
+
# import torch
|
4 |
+
# from diffusers import DDPMScheduler, UNet2DModel
|
5 |
+
# from PIL import Image
|
6 |
+
# import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# pipeline = DiffusionPipeline.from_pretrained("google/ddpm-cat-256")
|
9 |
pipeline = DiffusionPipeline.from_pretrained("google/ddpm-celebahq-256")
|
10 |
# pipeline.to("cuda")
|
11 |
|
12 |
+
def erzeuge(prompt):
|
13 |
+
return pipeline(prompt).images # [0]
|
14 |
+
|
15 |
|
16 |
with gr.Blocks() as demo:
|
17 |
with gr.Column(variant="panel"):
|
|
|
20 |
label="Deine Beschreibung:",
|
21 |
show_label=False,
|
22 |
max_lines=1,
|
23 |
+
placeholder="Bildbeschrei",
|
24 |
)
|
25 |
btn = gr.Button("erzeuge Bild")
|
26 |
|