Spaces:
Running
Running
import gradio as gr | |
from diffusers import StableDiffusionPipeline | |
import torch | |
# Load the Stable Diffusion model from Hugging Face's diffusers library | |
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4-original", torch_dtype=torch.float16) | |
pipe.to("cuda") | |
def generate_image(prompt): | |
# Generate the image based on the text prompt | |
image = pipe(prompt).images[0] | |
return image | |
# Create Gradio interface | |
interface = gr.Interface(fn=generate_image, | |
inputs="text", | |
outputs="image", | |
title="Text to Image Generator", | |
description="Generate images from text using Stable Diffusion.") | |
interface.launch() | |