import gradio as gr from diffusers import StableDiffusionPipeline import torch # Load the model without torch_dtype=torch.float16 pipe = StableDiffusionPipeline.from_pretrained( "CompVis/stable-diffusion-v1-4" ) pipe = pipe.to("cpu") # Force CPU def generate(prompt): image = pipe(prompt).images[0] return image gr.Interface(fn=generate, inputs="text", outputs="image").launch()