Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
# Load the model
|
6 |
+
@st.cache_resource
|
7 |
+
def load_pipeline():
|
8 |
+
return DiffusionPipeline.from_pretrained("IamCreateAI/Ruyi-Mini-7B")
|
9 |
+
|
10 |
+
pipe = load_pipeline()
|
11 |
+
|
12 |
+
# Streamlit App
|
13 |
+
st.title("AI Image Generator")
|
14 |
+
st.subheader("Generate stunning AI-powered images")
|
15 |
+
|
16 |
+
# Input for text prompt
|
17 |
+
prompt = st.text_input(
|
18 |
+
"Enter your prompt:",
|
19 |
+
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
|
20 |
+
)
|
21 |
+
|
22 |
+
if st.button("Generate Image"):
|
23 |
+
st.write("Generating image, please wait...")
|
24 |
+
try:
|
25 |
+
# Generate the image
|
26 |
+
image = pipe(prompt).images[0]
|
27 |
+
# Display the image
|
28 |
+
st.image(image, caption="Generated Image", use_column_width=True)
|
29 |
+
except Exception as e:
|
30 |
+
st.error(f"An error occurred: {e}")
|
31 |
+
|
32 |
+
st.write("Enter a creative prompt above and click the button to generate an AI-powered image!")
|