tejas1243 commited on
Commit
15b9514
·
verified ·
1 Parent(s): 40795d5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ # Load the model (Stable Diffusion XL)
6
+ pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
7
+ pipe.to("cpu") # CPU mode (free tier compatible)
8
+
9
+ # Function to generate an image
10
+ def generate_image(prompt):
11
+ image = pipe(prompt).images[0]
12
+ return image
13
+
14
+ # Gradio interface
15
+ demo = gr.Interface(
16
+ fn=generate_image,
17
+ inputs=gr.Textbox(label="Enter your image prompt"),
18
+ outputs="image",
19
+ title="Stable Diffusion XL (Free CPU Version)",
20
+ description="Generate images for free using CPU mode on Hugging Face"
21
+ )
22
+
23
+ demo.launch()