Spaces:
Running
Running
File size: 699 Bytes
81ac59f 9d1b8e4 f011d14 f6f44a7 f011d14 f6f44a7 |
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 28 29 30 31 |
from diffusers import StableDiffusionPipeline
import torch
import gradio as gr
# Load the model on CPU
model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id)
# Move the pipeline to CPU
pipe = pipe.to("cpu")
def generate_image(prompt):
image = pipe(prompt).images[0]
return image
# Define the chatbot function
def chatbot(prompt):
image = generate_image(prompt)
return image
# Create the Gradio interface
interface = gr.Interface(
fn=chatbot,
inputs="text",
outputs="image",
title="Text to Image Chatbot",
description="Generate images from text using Stable Diffusion"
)
# Launch the interface
interface.launch() |