File size: 696 Bytes
08acb07
 
 
c1d63ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
os.system("pip install diffusers torch transformers accelerate gradio")

import gradio as gr
from diffusers import StableDiffusionPipeline

# Load the Stable Diffusion model
model = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")

def generate_image(prompt):
    # Generate an image based on the prompt
    image = model(prompt).images[0]
    return image

# Create a Gradio interface
interface = gr.Interface(
    fn=generate_image,
    inputs="text",
    outputs="image",
    title="AI Image Generator",
    description="Enter a prompt to generate an image using Stable Diffusion."
)

# Launch the interface
if __name__ == "__main__":
    interface.launch()