Vijjichenna's picture
Update app.py
08acb07 verified
raw
history blame
696 Bytes
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()