Spaces:
Sleeping
Sleeping
Commit ·
ddc97d7
1
Parent(s): 06f915b
debug 13
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from diffusers import DiffusionPipeline
|
|
|
|
| 3 |
# import torch
|
| 4 |
# from diffusers import DDPMScheduler, UNet2DModel
|
| 5 |
# from PIL import Image
|
|
@@ -9,6 +10,7 @@ from diffusers import DiffusionPipeline
|
|
| 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 |
|
|
@@ -33,11 +35,3 @@ with gr.Blocks() as demo:
|
|
| 33 |
|
| 34 |
if __name__ == "__main__":
|
| 35 |
demo.launch()
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from diffusers import DiffusionPipeline
|
| 3 |
+
|
| 4 |
# import torch
|
| 5 |
# from diffusers import DDPMScheduler, UNet2DModel
|
| 6 |
# from PIL import Image
|
|
|
|
| 10 |
pipeline = DiffusionPipeline.from_pretrained("google/ddpm-celebahq-256")
|
| 11 |
# pipeline.to("cuda")
|
| 12 |
|
| 13 |
+
|
| 14 |
def erzeuge(prompt):
|
| 15 |
return pipeline(prompt).images # [0]
|
| 16 |
|
|
|
|
| 35 |
|
| 36 |
if __name__ == "__main__":
|
| 37 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app1.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
# from diffusers import DiffusionPipeline
|
| 2 |
-
from diffusers import DDPMPipeline, DDIMPipeline, PNDMPipeline
|
| 3 |
-
import torch
|
| 4 |
-
import gradio as gr
|
| 5 |
-
import random
|
| 6 |
-
|
| 7 |
-
pipeline = DDPMPipeline.from_pretrained("google/ddpm-cat-256")
|
| 8 |
-
# pipeline.to("cuda")
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
def predict(steps, seed):
|
| 12 |
-
generator = torch.manual_seed(seed)
|
| 13 |
-
for i in range(1, steps):
|
| 14 |
-
yield pipeline(generator=generator, num_inference_steps=i).images[0]
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
random_seed = random.randint(0, 2147483647)
|
| 18 |
-
gr.Interface(
|
| 19 |
-
predict,
|
| 20 |
-
inputs=[
|
| 21 |
-
gr.inputs.Slider(1, 100, label="Inference Steps", default=5, step=1),
|
| 22 |
-
gr.inputs.Slider(0, 2147483647, label="Seed", default=random_seed, step=1),
|
| 23 |
-
],
|
| 24 |
-
outputs=gr.Image(shape=[128, 128], type="pil", elem_id="output_image"),
|
| 25 |
-
css="#output_image{width: 256px}",
|
| 26 |
-
title="Unconditional butterflies",
|
| 27 |
-
description="图片生成器",
|
| 28 |
-
).queue().launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|