Aashi commited on
Commit
47d9d40
β€’
1 Parent(s): 429be58

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/NSTiwari/SDXL_LoRA_model").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import torch
3
+ from diffusers import AutoPipelineForImage2Image
4
+ from diffusers.utils import make_image_grid, load_image
5
 
6
+ gr.load("models/NSTiwari/SDXL_LoRA_model").launch()
7
+
8
+ pipeline = AutoPipelineForImage2Image.from_pretrained(
9
+ "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
10
+ )
11
+ pipeline.load_lora_weights('/content/SDXL_LoRA_model/pytorch_lora_weights.safetensors')
12
+ _ = pipeline.to("cuda")
13
+
14
+ pipeline.enable_model_cpu_offload()
15
+
16
+ url = "https://img.onmanorama.com/content/dam/mm/en/lifestyle/decor/images/2020/12/1/25-lakh-living-hall.jpg.transform/576x300/image.jpg"
17
+ init_image = load_image(url)
18
+ image = init_image.resize((1024, 576))
19
+
20
+ prompt = "A cozy Indian living room glows with morning sunshine on Republic Day, its walls decked in saffron, white, and green tapestries and art, while colorful cushions and festive garlands add a vibrant, celebratory air."
21
+
22
+ # pass prompt and image to pipeline
23
+ image_out = pipeline(prompt, image=image, strength=0.5).images[0]
24
+ make_image_grid([image, image_out], rows=1, cols=2)