File size: 703 Bytes
cebd403
0ab81be
25e36cf
 
 
cebd403
cdaf8b0
 
 
0ab81be
25e36cf
cdaf8b0
0ab81be
cebd403
cdaf8b0
cebd403
25e36cf
cebd403
0ab81be
25e36cf
0ab81be
cebd403
0ab81be
 
cdaf8b0
 
 
 
0ab81be
cebd403
0ab81be
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
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()