Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,12 +3,12 @@ from diffusers import DiffusionPipeline
|
|
| 3 |
import torch
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
# Load
|
| 7 |
@st.cache_resource
|
| 8 |
def load_model():
|
| 9 |
model_id = "xinsir/controlnet-union-sdxl-1.0"
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 11 |
-
pipe =
|
| 12 |
pipe.to(device)
|
| 13 |
return pipe
|
| 14 |
|
|
@@ -41,4 +41,4 @@ if st.button("Generate Image"):
|
|
| 41 |
st.image(file_path, caption=f"Generated Image {i+1}")
|
| 42 |
st.success(f"Saved image to {file_path}")
|
| 43 |
|
| 44 |
-
st.balloons()
|
|
|
|
| 3 |
import torch
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
# Load Diffusion model
|
| 7 |
@st.cache_resource
|
| 8 |
def load_model():
|
| 9 |
model_id = "xinsir/controlnet-union-sdxl-1.0"
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 11 |
+
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if device == "cuda" else torch.float32)
|
| 12 |
pipe.to(device)
|
| 13 |
return pipe
|
| 14 |
|
|
|
|
| 41 |
st.image(file_path, caption=f"Generated Image {i+1}")
|
| 42 |
st.success(f"Saved image to {file_path}")
|
| 43 |
|
| 44 |
+
st.balloons()
|