Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,31 +6,26 @@ import torch
|
|
6 |
from PIL import Image
|
7 |
import io
|
8 |
|
9 |
-
# Load model on CPU only
|
10 |
@st.cache_resource
|
11 |
def load_model():
|
|
|
12 |
pipe = StableDiffusionPipeline.from_pretrained(
|
13 |
-
"runwayml/stable-diffusion-v1-5"
|
14 |
-
torch_dtype=torch.float32, # CPU needs float32
|
15 |
-
use_auth_token=True # If needed for private models
|
16 |
)
|
17 |
-
pipe.to("cpu")
|
18 |
return pipe
|
19 |
|
20 |
-
|
21 |
-
st.title("🎨 AI Image Generator (CPU Compatible)")
|
22 |
-
st.markdown("No GPU? No problem. This app runs Stable Diffusion entirely on your CPU.")
|
23 |
|
24 |
-
prompt = st.
|
25 |
-
|
26 |
|
27 |
-
guidance = st.slider("
|
28 |
|
29 |
-
if st.button("Generate
|
30 |
-
with st.spinner("Generating
|
31 |
pipe = load_model()
|
32 |
image = pipe(prompt, guidance_scale=guidance).images[0]
|
33 |
-
|
34 |
st.image(image, caption="Generated Image", use_column_width=True)
|
35 |
|
36 |
buf = io.BytesIO()
|
|
|
6 |
from PIL import Image
|
7 |
import io
|
8 |
|
|
|
9 |
@st.cache_resource
|
10 |
def load_model():
|
11 |
+
# Force CPU-only execution
|
12 |
pipe = StableDiffusionPipeline.from_pretrained(
|
13 |
+
"runwayml/stable-diffusion-v1-5"
|
|
|
|
|
14 |
)
|
15 |
+
pipe.to("cpu")
|
16 |
return pipe
|
17 |
|
18 |
+
st.title("🧠 AI Image Generator (CPU Only)")
|
|
|
|
|
19 |
|
20 |
+
prompt = st.text_input("Enter your prompt:",
|
21 |
+
"A surreal multi-dimensional fractal landscape in vivid colors")
|
22 |
|
23 |
+
guidance = st.slider("Guidance scale (higher = more creative)", 1.0, 20.0, 7.5)
|
24 |
|
25 |
+
if st.button("Generate"):
|
26 |
+
with st.spinner("Generating on CPU... please wait 2–5 minutes."):
|
27 |
pipe = load_model()
|
28 |
image = pipe(prompt, guidance_scale=guidance).images[0]
|
|
|
29 |
st.image(image, caption="Generated Image", use_column_width=True)
|
30 |
|
31 |
buf = io.BytesIO()
|