Text-to-Image / app.py
Dannyar608's picture
Update app.py
70eb5ba verified
raw
history blame
626 Bytes
import gradio as gr
from transformers import pipeline
# Load Stable Diffusion model from Hugging Face
generator = pipeline("text-to-image", model="stabilityai/stable-diffusion-3-medium-diffusers")
# Define the chatbot function
def generate_image(prompt: str):
# Generate the image from the prompt
image = generator(prompt)[0]["image"]
return image
# Create the Gradio interface
iface = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="Enter a description of the image"),
outputs=gr.Image(label="Generated Image"),
live=True
)
# Launch the Gradio interface
iface.launch(share=True)