Spaces:
Sleeping
Sleeping
Commit
·
e6a0177
1
Parent(s):
4bdae97
debug
Browse files- app.py +26 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
def predict(steps, seed):
|
11 |
+
generator = torch.manual_seed(seed)
|
12 |
+
for i in range(1,steps):
|
13 |
+
yield pipeline(generator=generator, num_inference_steps=i).images[0]
|
14 |
+
|
15 |
+
random_seed = random.randint(0, 2147483647)
|
16 |
+
gr.Interface(
|
17 |
+
predict,
|
18 |
+
inputs=[
|
19 |
+
gr.inputs.Slider(1, 100, label='Inference Steps', default=5, step=1),
|
20 |
+
gr.inputs.Slider(0, 2147483647, label='Seed', default=random_seed, step=1),
|
21 |
+
],
|
22 |
+
outputs=gr.Image(shape=[128,128], type="pil", elem_id="output_image"),
|
23 |
+
css="#output_image{width: 256px}",
|
24 |
+
title="Unconditional butterflies",
|
25 |
+
description="图片生成器",
|
26 |
+
).queue().launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
diffusers==0.23.1
|
2 |
+
gradio==4.4.1
|