Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,45 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import random
|
4 |
-
from diffusers import
|
5 |
import torch
|
6 |
|
7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
|
9 |
if torch.cuda.is_available():
|
10 |
torch.cuda.max_memory_allocated(device=device)
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
else:
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
MAX_SEED = np.iinfo(np.int32).max
|
19 |
MAX_IMAGE_SIZE = 1024
|
20 |
|
21 |
-
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
22 |
|
23 |
if randomize_seed:
|
24 |
seed = random.randint(0, MAX_SEED)
|
@@ -32,7 +53,8 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
32 |
num_inference_steps = num_inference_steps,
|
33 |
width = width,
|
34 |
height = height,
|
35 |
-
generator = generator
|
|
|
36 |
).images[0]
|
37 |
|
38 |
return image
|
@@ -41,6 +63,8 @@ examples = [
|
|
41 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
42 |
"An astronaut riding a green horse",
|
43 |
"A delicious ceviche cheesecake slice",
|
|
|
|
|
44 |
]
|
45 |
|
46 |
css="""
|
@@ -59,8 +83,14 @@ with gr.Blocks(css=css) as demo:
|
|
59 |
|
60 |
with gr.Column(elem_id="col-container"):
|
61 |
gr.Markdown(f"""
|
62 |
-
#
|
63 |
Currently running on {power_device}.
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
""")
|
65 |
|
66 |
with gr.Row():
|
@@ -100,18 +130,18 @@ with gr.Blocks(css=css) as demo:
|
|
100 |
|
101 |
width = gr.Slider(
|
102 |
label="Width",
|
103 |
-
minimum=
|
104 |
maximum=MAX_IMAGE_SIZE,
|
105 |
step=32,
|
106 |
-
value=
|
107 |
)
|
108 |
|
109 |
height = gr.Slider(
|
110 |
label="Height",
|
111 |
-
minimum=
|
112 |
maximum=MAX_IMAGE_SIZE,
|
113 |
step=32,
|
114 |
-
value=
|
115 |
)
|
116 |
|
117 |
with gr.Row():
|
@@ -121,16 +151,24 @@ with gr.Blocks(css=css) as demo:
|
|
121 |
minimum=0.0,
|
122 |
maximum=10.0,
|
123 |
step=0.1,
|
124 |
-
value=
|
125 |
)
|
126 |
|
127 |
num_inference_steps = gr.Slider(
|
128 |
label="Number of inference steps",
|
129 |
minimum=1,
|
130 |
-
maximum=
|
131 |
step=1,
|
132 |
-
value=
|
133 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
gr.Examples(
|
136 |
examples = examples,
|
@@ -139,7 +177,7 @@ with gr.Blocks(css=css) as demo:
|
|
139 |
|
140 |
run_button.click(
|
141 |
fn = infer,
|
142 |
-
inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
143 |
outputs = [result]
|
144 |
)
|
145 |
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import random
|
4 |
+
from diffusers import StableDiffusionXLPipeline, KDPM2AncestralDiscreteScheduler, AutoencoderKL
|
5 |
import torch
|
6 |
|
7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
|
9 |
if torch.cuda.is_available():
|
10 |
torch.cuda.max_memory_allocated(device=device)
|
11 |
+
# Load VAE component
|
12 |
+
vae = AutoencoderKL.from_pretrained(
|
13 |
+
"madebyollin/sdxl-vae-fp16-fix",
|
14 |
+
torch_dtype=torch.float16
|
15 |
+
)
|
16 |
+
|
17 |
+
# Configure the pipeline
|
18 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(
|
19 |
+
"dataautogpt3/ProteusV0.5",
|
20 |
+
vae=vae,
|
21 |
+
torch_dtype=torch.float16
|
22 |
+
)
|
23 |
+
pipe.scheduler = KDPM2AncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
24 |
+
pipe.to(device)
|
25 |
else:
|
26 |
+
# Load VAE component
|
27 |
+
vae = AutoencoderKL.from_pretrained(
|
28 |
+
"madebyollin/sdxl-vae-fp16-fix",
|
29 |
+
)
|
30 |
+
|
31 |
+
# Configure the pipeline
|
32 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(
|
33 |
+
"dataautogpt3/ProteusV0.5",
|
34 |
+
vae=vae,
|
35 |
+
)
|
36 |
+
pipe.scheduler = KDPM2AncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
37 |
+
pipe.to(device)
|
38 |
|
39 |
MAX_SEED = np.iinfo(np.int32).max
|
40 |
MAX_IMAGE_SIZE = 1024
|
41 |
|
42 |
+
def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, clip_skip):
|
43 |
|
44 |
if randomize_seed:
|
45 |
seed = random.randint(0, MAX_SEED)
|
|
|
53 |
num_inference_steps = num_inference_steps,
|
54 |
width = width,
|
55 |
height = height,
|
56 |
+
generator = generator,
|
57 |
+
clip_skip = clip_skip
|
58 |
).images[0]
|
59 |
|
60 |
return image
|
|
|
63 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
64 |
"An astronaut riding a green horse",
|
65 |
"A delicious ceviche cheesecake slice",
|
66 |
+
"black fluffy gorgeous dangerous cat animal creature, large orange eyes, big fluffy ears, piercing gaze, full moon, dark ambiance, best quality, extremely detailed",
|
67 |
+
"high quality pixel art, a pixel art silhouette of an anime space-themed girl in a space-punk steampunk style, lying in her bed by the window of a spaceship, smoking, with a rustic feel. The image should embody epic portraiture and double exposure, featuring an isolated landscape visible through the window. The colors should primarily be dynamic and action-packed, with a strong use of negative space. The entire artwork should be in pixel art style, emphasizing the characters shape and set against a white background. Silhouette"
|
68 |
]
|
69 |
|
70 |
css="""
|
|
|
83 |
|
84 |
with gr.Column(elem_id="col-container"):
|
85 |
gr.Markdown(f"""
|
86 |
+
# ProteusV0.5 Demo
|
87 |
Currently running on {power_device}.
|
88 |
+
|
89 |
+
ProteusV0.5 is a state-of-the-art text-to-image model that leverages the power of Stable Diffusion to generate high-quality images from text prompts. This model has been fine-tuned on a large dataset of images and has been trained to understand a wide range of prompts and styles.
|
90 |
+
|
91 |
+
With ProteusV0.5, you can generate images in a variety of styles, from realistic to abstract, and from simple to complex. The model is also capable of understanding and responding to complex prompts, making it a powerful tool for artists, designers, and anyone looking to generate high-quality images.
|
92 |
+
|
93 |
+
To use this demo, simply enter a text prompt in the input field below, and the model will generate an image based on your prompt. You can also adjust the settings to control the quality and style of the generated image.
|
94 |
""")
|
95 |
|
96 |
with gr.Row():
|
|
|
130 |
|
131 |
width = gr.Slider(
|
132 |
label="Width",
|
133 |
+
minimum=512,
|
134 |
maximum=MAX_IMAGE_SIZE,
|
135 |
step=32,
|
136 |
+
value=1024,
|
137 |
)
|
138 |
|
139 |
height = gr.Slider(
|
140 |
label="Height",
|
141 |
+
minimum=512,
|
142 |
maximum=MAX_IMAGE_SIZE,
|
143 |
step=32,
|
144 |
+
value=1024,
|
145 |
)
|
146 |
|
147 |
with gr.Row():
|
|
|
151 |
minimum=0.0,
|
152 |
maximum=10.0,
|
153 |
step=0.1,
|
154 |
+
value=7.0,
|
155 |
)
|
156 |
|
157 |
num_inference_steps = gr.Slider(
|
158 |
label="Number of inference steps",
|
159 |
minimum=1,
|
160 |
+
maximum=50,
|
161 |
step=1,
|
162 |
+
value=50,
|
163 |
)
|
164 |
+
|
165 |
+
clip_skip = gr.Slider(
|
166 |
+
label="Clip skip",
|
167 |
+
minimum=1,
|
168 |
+
maximum=12,
|
169 |
+
step=1,
|
170 |
+
value=2,
|
171 |
+
)
|
172 |
|
173 |
gr.Examples(
|
174 |
examples = examples,
|
|
|
177 |
|
178 |
run_button.click(
|
179 |
fn = infer,
|
180 |
+
inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps, clip_skip],
|
181 |
outputs = [result]
|
182 |
)
|
183 |
|