import torch import gradio as gr from diffusers import StableDiffusionPipeline model_id = "runwayml/stable-diffusion-v1-5" device = "cuda" if torch.cuda.is_available() else "cpu" pipe = StableDiffusionPipeline.from_pretrained( model_id, torch_dtype=torch.float16 if device == "cuda" else torch.float32 ) pipe = pipe.to(device) pipe.load_lora_weights("./") def generate(prompt): image = pipe(prompt).images[0] return image demo = gr.Interface( fn=generate, inputs=gr.Textbox(label="Enter your prompt"), outputs=gr.Image(type="pil"), title="Zenma AI Image Generator", description="Generate images using a fine-tuned Stable Diffusion LoRA model" ) demo.launch()