Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,30 @@
|
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
import random
|
5 |
-
from diffusers import DiffusionPipeline
|
|
|
6 |
import torch
|
7 |
import spaces
|
8 |
|
9 |
-
pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
10 |
-
pipe = pipe.to("cuda")
|
11 |
|
12 |
MAX_SEED = np.iinfo(np.int32).max
|
13 |
-
MAX_IMAGE_SIZE =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
@spaces.GPU
|
16 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
@@ -86,7 +101,7 @@ with gr.Blocks(css=css) as demo:
|
|
86 |
minimum=256,
|
87 |
maximum=MAX_IMAGE_SIZE,
|
88 |
step=32,
|
89 |
-
value=
|
90 |
)
|
91 |
|
92 |
height = gr.Slider(
|
@@ -94,7 +109,7 @@ with gr.Blocks(css=css) as demo:
|
|
94 |
minimum=256,
|
95 |
maximum=MAX_IMAGE_SIZE,
|
96 |
step=32,
|
97 |
-
value=
|
98 |
)
|
99 |
|
100 |
with gr.Row():
|
@@ -102,17 +117,17 @@ with gr.Blocks(css=css) as demo:
|
|
102 |
guidance_scale = gr.Slider(
|
103 |
label="Guidance scale",
|
104 |
minimum=0.0,
|
105 |
-
maximum=
|
106 |
step=0.1,
|
107 |
-
value=
|
108 |
)
|
109 |
|
110 |
num_inference_steps = gr.Slider(
|
111 |
label="Number of inference steps",
|
112 |
minimum=1,
|
113 |
-
maximum=
|
114 |
step=1,
|
115 |
-
value=
|
116 |
)
|
117 |
|
118 |
run_button.click(
|
|
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
import random
|
5 |
+
#from diffusers import DiffusionPipeline
|
6 |
+
from diffusers import StableDiffusionXLPipeline
|
7 |
import torch
|
8 |
import spaces
|
9 |
|
|
|
|
|
10 |
|
11 |
MAX_SEED = np.iinfo(np.int32).max
|
12 |
+
MAX_IMAGE_SIZE = 1216
|
13 |
+
|
14 |
+
#pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
15 |
+
#pipe = pipe.to("cuda")
|
16 |
+
|
17 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(
|
18 |
+
"yodayo-ai/holodayo-xl-2.1",
|
19 |
+
torch_dtype=torch.float16,
|
20 |
+
use_safetensors=True,
|
21 |
+
custom_pipeline="lpw_stable_diffusion_xl",
|
22 |
+
add_watermarker=False,
|
23 |
+
variant="fp16"
|
24 |
+
)
|
25 |
+
pipe.to('cuda')
|
26 |
+
|
27 |
+
prompt = "1girl, solo, upper body, v, smile, looking at viewer, outdoors, night, masterpiece, best quality, very aesthetic, absurdres"
|
28 |
+
negative_prompt = "nsfw, (low quality, worst quality:1.2), very displeasing, 3d, watermark, signature, ugly, poorly drawn"
|
29 |
|
30 |
@spaces.GPU
|
31 |
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
|
|
101 |
minimum=256,
|
102 |
maximum=MAX_IMAGE_SIZE,
|
103 |
step=32,
|
104 |
+
value=832,
|
105 |
)
|
106 |
|
107 |
height = gr.Slider(
|
|
|
109 |
minimum=256,
|
110 |
maximum=MAX_IMAGE_SIZE,
|
111 |
step=32,
|
112 |
+
value=1216,
|
113 |
)
|
114 |
|
115 |
with gr.Row():
|
|
|
117 |
guidance_scale = gr.Slider(
|
118 |
label="Guidance scale",
|
119 |
minimum=0.0,
|
120 |
+
maximum=20.0,
|
121 |
step=0.1,
|
122 |
+
value=7,
|
123 |
)
|
124 |
|
125 |
num_inference_steps = gr.Slider(
|
126 |
label="Number of inference steps",
|
127 |
minimum=1,
|
128 |
+
maximum=28,
|
129 |
step=1,
|
130 |
+
value=28,
|
131 |
)
|
132 |
|
133 |
run_button.click(
|