Muthuraja18 commited on
Commit
4be8575
·
verified ·
1 Parent(s): e8176a8

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +38 -0
  2. requirements.txt +9 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import streamlit as st
4
+ from diffusers import StableDiffusionPipeline
5
+ import torch
6
+ from PIL import Image
7
+ import io
8
+
9
+ # Load model once
10
+ @st.cache_resource
11
+ def load_model():
12
+ pipe = StableDiffusionPipeline.from_pretrained(
13
+ "runwayml/stable-diffusion-v1-5", # You can change this to another model
14
+ torch_dtype=torch.float16
15
+ )
16
+ return pipe.to("cuda")
17
+
18
+ # Streamlit app UI
19
+ st.title("🧠 AI Image Generator (Stable Diffusion)")
20
+ st.markdown("Generate original, multidimensional images using Stable Diffusion!")
21
+
22
+ prompt = st.text_area("Enter your creative prompt:",
23
+ "A multi-dimensional alien city with glowing fractals, floating geometry, cosmic lighting, 8K resolution")
24
+
25
+ guidance = st.slider("Creativity (Guidance Scale)", 1.0, 20.0, 8.5)
26
+
27
+ if st.button("Generate Image"):
28
+ with st.spinner("Generating image..."):
29
+ pipe = load_model()
30
+ image = pipe(prompt, guidance_scale=guidance).images[0]
31
+
32
+ st.image(image, caption="Generated Image", use_column_width=True)
33
+
34
+ # Download button
35
+ buf = io.BytesIO()
36
+ image.save(buf, format="PNG")
37
+ byte_im = buf.getvalue()
38
+ st.download_button("Download Image", byte_im, "generated.png", "image/png")
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ torch
3
+ torchvision
4
+ torchaudio
5
+ diffusers
6
+ transformers
7
+ accelerate
8
+ safetensors
9
+ Pillow