Spaces:
Runtime error
Runtime error
Commit
Β·
a771b6a
1
Parent(s):
6cf932e
use pipeline
Browse files
app.py
CHANGED
@@ -1,22 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
# from PIL import Image
|
4 |
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
device="cuda"
|
|
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
10 |
|
11 |
def resize(w_val,l_val,img):
|
12 |
img = Image.open(img)
|
13 |
img = img.resize((w_val,l_val), Image.Resampling.LANCZOS)
|
14 |
return img
|
15 |
|
16 |
-
|
17 |
def infer(prompt, guide, steps, width, height):
|
18 |
-
|
19 |
-
output = io1_text2img(prompt, guidance_scale=guide, num_inference_steps=steps, width=width, height=height)
|
20 |
image = output.images[0]
|
21 |
return image
|
22 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image
|
|
|
3 |
|
4 |
+
from diffusers import (
|
5 |
+
StableDiffusionPipeline,
|
6 |
+
StableDiffusionImg2ImgPipeline,
|
7 |
+
StableDiffusionInpaintPipeline,
|
8 |
+
)
|
9 |
|
10 |
device="cuda"
|
11 |
+
model_id = "IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1"
|
12 |
|
13 |
+
pipe_text2img = StableDiffusionPipeline.from_pretrained(model_id).to(device)
|
14 |
+
pipe_img2img = StableDiffusionImg2ImgPipeline(**pipe_text2img.components)
|
15 |
+
pipe_inpaint = StableDiffusionInpaintPipeline(**pipe_text2img.components)
|
16 |
+
|
17 |
+
# io1_text2img = gr.Interface.load("models/IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1")
|
18 |
|
19 |
def resize(w_val,l_val,img):
|
20 |
img = Image.open(img)
|
21 |
img = img.resize((w_val,l_val), Image.Resampling.LANCZOS)
|
22 |
return img
|
23 |
|
|
|
24 |
def infer(prompt, guide, steps, width, height):
|
25 |
+
output = pipe_text2img(prompt, guidance_scale=guide, num_inference_steps=steps, width=width, height=height)
|
26 |
+
# output = io1_text2img(prompt, guidance_scale=guide, num_inference_steps=steps, width=width, height=height)
|
27 |
image = output.images[0]
|
28 |
return image
|
29 |
|