sergon19 commited on
Commit
35e3eb3
Β·
verified Β·
1 Parent(s): 896c7ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,3 +1,24 @@
1
  import gradio as gr
2
 
3
- gr.load("models/sergon19/green_bg_LoRa10").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ #gr.load("models/sergon19/green_bg_LoRa10").launch()
4
+
5
+ import torch
6
+ from diffusers import DiffusionPipeline, AutoencoderKL
7
+
8
+ vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
9
+ pipe = DiffusionPipeline.from_pretrained(
10
+ "stabilityai/stable-diffusion-xl-base-1.0",
11
+ vae=vae,
12
+ torch_dtype=torch.float16,
13
+ variant="fp16",
14
+ use_safetensors=True
15
+ )
16
+ pipe.load_lora_weights("sergon19/green_bg_LoRa10")
17
+ _ = pipe.to("cuda")
18
+
19
+ def generate_image(prompt):
20
+ image = pipe(prompt=prompt, num_inference_steps=25).images[0]
21
+ return image
22
+
23
+ iface = gr.Interface(fn=generate_image, inputs="text", outputs="image")
24
+ iface.launch()