Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,8 @@ import torch
|
|
9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
10 |
model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to use
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
else:
|
15 |
-
torch_dtype = torch.float32
|
16 |
|
17 |
pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
|
18 |
pipe = pipe.to(device)
|
@@ -20,7 +18,6 @@ pipe = pipe.to(device)
|
|
20 |
MAX_SEED = np.iinfo(np.int32).max
|
21 |
MAX_IMAGE_SIZE = 1024
|
22 |
|
23 |
-
|
24 |
# @spaces.GPU #[uncomment to use ZeroGPU]
|
25 |
def infer(
|
26 |
prompt,
|
@@ -50,7 +47,6 @@ def infer(
|
|
50 |
|
51 |
return image, seed
|
52 |
|
53 |
-
|
54 |
examples = [
|
55 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
56 |
"An astronaut riding a green horse",
|
@@ -105,7 +101,7 @@ with gr.Blocks(css=css) as demo:
|
|
105 |
minimum=256,
|
106 |
maximum=MAX_IMAGE_SIZE,
|
107 |
step=32,
|
108 |
-
value=1024,
|
109 |
)
|
110 |
|
111 |
height = gr.Slider(
|
@@ -113,7 +109,7 @@ with gr.Blocks(css=css) as demo:
|
|
113 |
minimum=256,
|
114 |
maximum=MAX_IMAGE_SIZE,
|
115 |
step=32,
|
116 |
-
value=1024,
|
117 |
)
|
118 |
|
119 |
with gr.Row():
|
@@ -122,7 +118,7 @@ with gr.Blocks(css=css) as demo:
|
|
122 |
minimum=0.0,
|
123 |
maximum=10.0,
|
124 |
step=0.1,
|
125 |
-
value=0.0,
|
126 |
)
|
127 |
|
128 |
num_inference_steps = gr.Slider(
|
@@ -130,7 +126,7 @@ with gr.Blocks(css=css) as demo:
|
|
130 |
minimum=1,
|
131 |
maximum=50,
|
132 |
step=1,
|
133 |
-
value=2,
|
134 |
)
|
135 |
|
136 |
gr.Examples(examples=examples, inputs=[prompt])
|
|
|
9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
10 |
model_repo_id = "stabilityai/sdxl-turbo" # Replace to the model you would like to use
|
11 |
|
12 |
+
# Force model to use float32 to avoid dtype mismatch
|
13 |
+
torch_dtype = torch.float32
|
|
|
|
|
14 |
|
15 |
pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
|
16 |
pipe = pipe.to(device)
|
|
|
18 |
MAX_SEED = np.iinfo(np.int32).max
|
19 |
MAX_IMAGE_SIZE = 1024
|
20 |
|
|
|
21 |
# @spaces.GPU #[uncomment to use ZeroGPU]
|
22 |
def infer(
|
23 |
prompt,
|
|
|
47 |
|
48 |
return image, seed
|
49 |
|
|
|
50 |
examples = [
|
51 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
52 |
"An astronaut riding a green horse",
|
|
|
101 |
minimum=256,
|
102 |
maximum=MAX_IMAGE_SIZE,
|
103 |
step=32,
|
104 |
+
value=1024,
|
105 |
)
|
106 |
|
107 |
height = gr.Slider(
|
|
|
109 |
minimum=256,
|
110 |
maximum=MAX_IMAGE_SIZE,
|
111 |
step=32,
|
112 |
+
value=1024,
|
113 |
)
|
114 |
|
115 |
with gr.Row():
|
|
|
118 |
minimum=0.0,
|
119 |
maximum=10.0,
|
120 |
step=0.1,
|
121 |
+
value=0.0,
|
122 |
)
|
123 |
|
124 |
num_inference_steps = gr.Slider(
|
|
|
126 |
minimum=1,
|
127 |
maximum=50,
|
128 |
step=1,
|
129 |
+
value=2,
|
130 |
)
|
131 |
|
132 |
gr.Examples(examples=examples, inputs=[prompt])
|