Samarashweiki commited on
Commit
526a2ac
·
verified ·
1 Parent(s): d332182

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ # Load model
6
+ model_id = "ostris/Flex.2-preview"
7
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
8
+ pipe.to("cuda")
9
+
10
+ # Inference function
11
+ def generate_image(prompt):
12
+ image = pipe(prompt).images[0]
13
+ return image
14
+
15
+ # Gradio interface
16
+ interface = gr.Interface(fn=generate_image,
17
+ inputs=gr.Textbox(label="Enter your prompt"),
18
+ outputs=gr.Image(type="pil"),
19
+ title="Text to Image Generator",
20
+ description="Generate images from your text prompts using Stable Diffusion.")
21
+
22
+ interface.launch()