Vijjichenna's picture
Update app.py
d3db117 verified
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()
model = StableDiffusionPipeline.from_pretrained("SG161222/Realistic_Vision_V4.0")
import torch
from diffusers import StableDiffusionPipeline
model = StableDiffusionPipeline.from_pretrained("SG161222/Realistic_Vision_V4.0").to("cuda")
model.unet = torch.compile(model.unet) # Speeds up inference
def generate_image(prompt):
image = model(prompt).images[0]
return image