File size: 691 Bytes
433982d
 
35e3eb3
 
 
 
 
3f1dec5
35e3eb3
 
 
3f1dec5
 
35e3eb3
 
 
3f1dec5
35e3eb3
 
 
 
 
 
3f1dec5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr

#gr.load("models/sergon19/green_bg_LoRa10").launch()

import torch
from diffusers import DiffusionPipeline, AutoencoderKL

vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    vae=vae,
    torch_dtype=torch.float16,
    variant="fp16",
    use_safetensors=True
)
pipe.load_lora_weights("sergon19/green_bg_LoRa10")
_ = pipe.to("cuda")

def generate_image(prompt):
    image = pipe(prompt=prompt, num_inference_steps=25).images[0]
    return image

iface = gr.Interface(fn=generate_image, inputs="text", outputs="image")
iface.launch()