Spaces:
Running
Running
File size: 574 Bytes
48836eb 06396f2 48836eb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch
model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cpu") # GPU के बजाय CPU सेट करें
def generate_image(prompt):
image = pipe(prompt).images[0]
return image
interface = gr.Interface(
fn=generate_image,
inputs=gr.Textbox(label="Enter your text prompt"),
outputs=gr.Image(label="Generated Image"),
title="Text-to-Image Generator"
)
interface.launch() |