DetectiveShadow commited on
Commit
af770ce
·
verified ·
1 Parent(s): 2851543

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -4,5 +4,30 @@ import streamlit as st
4
  st.title("👋 Hello Coder")
5
  st.write("Welcome to your Hugging Face Space!")
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  x = st.slider('Select a value')
8
  st.write(x, 'squared is', x * x)
 
4
  st.title("👋 Hello Coder")
5
  st.write("Welcome to your Hugging Face Space!")
6
 
7
+
8
+ import torch
9
+ from diffusers import DiffusionPipeline
10
+
11
+ @st.cache_resource
12
+ def load_pipe():
13
+ pipe = DiffusionPipeline.from_pretrained(
14
+ "stabilityai/stable-diffusion-xl-base-1.0",
15
+ torch_dtype=torch.float16,
16
+ variant="fp16",
17
+ use_safetensors=True
18
+ ).to("cuda")
19
+ pipe.load_lora_weights("ZB-Tech/Text-to-Image")
20
+ return pipe
21
+
22
+ st.title("🎨 AI Image Generator")
23
+ prompt = st.text_input("Enter a prompt:", "Draw a picture of some coding on a screen with a horror background")
24
+
25
+ if st.button("Generate"):
26
+ with st.spinner("Generating image..."):
27
+ pipe = load_pipe()
28
+ image = pipe(prompt).images[0]
29
+ st.image(image, caption="Generated Image", use_column_width=True)
30
+
31
+
32
  x = st.slider('Select a value')
33
  st.write(x, 'squared is', x * x)