Spaces:
Sleeping
Sleeping
delete app.py
Browse files
app.py
DELETED
|
@@ -1,29 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from diffusers import StableDiffusionPipeline
|
| 3 |
-
import torch
|
| 4 |
-
|
| 5 |
-
# Load the model
|
| 6 |
-
@st.cache_resource
|
| 7 |
-
def load_model():
|
| 8 |
-
model_id = "CompVis/stable-diffusion-v1-4"
|
| 9 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id)
|
| 10 |
-
pipe = pipe.to("cpu") # Ensure the model runs on CPU
|
| 11 |
-
return pipe
|
| 12 |
-
|
| 13 |
-
pipe = load_model()
|
| 14 |
-
|
| 15 |
-
# Streamlit UI
|
| 16 |
-
st.title("Text-to-Image Generator")
|
| 17 |
-
st.write("Enter a description, and the AI model will generate an image!")
|
| 18 |
-
|
| 19 |
-
# User input
|
| 20 |
-
text_input = st.text_input("Enter your description:")
|
| 21 |
-
|
| 22 |
-
# Generate and display image
|
| 23 |
-
if text_input:
|
| 24 |
-
with st.spinner("Generating image... Please wait ⏳"):
|
| 25 |
-
try:
|
| 26 |
-
image = pipe(text_input).images[0] # Generate image
|
| 27 |
-
st.image(image, caption="Generated Image", use_column_width=True)
|
| 28 |
-
except Exception as e:
|
| 29 |
-
st.error(f"Error generating image: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|