Aashi commited on
Commit
e5f23f6
β€’
1 Parent(s): de210ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -5
app.py CHANGED
@@ -3,22 +3,41 @@ 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)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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('pytorch_lora_weights_00.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)
25
+
26
+
27
+ # Define the image generation function
28
+ def generate_image(prompt, image_url):
29
+ init_image = load_image(image_url)
30
+ image = init_image.resize((1024, 576))
31
+ image_out = pipeline(prompt, image=image, strength=0.5).images[0]
32
+ return image_out
33
+
34
+
35
+ # Set up Gradio interface
36
+ iface = gr.Interface(
37
+ fn=generate_image,
38
+ inputs=[gr.Textbox(label="Prompt"), gr.Textbox(label="Image URL")],
39
+ outputs="image"
40
+ )
41
+
42
+ # Launch the Gradio app
43
+ iface.launch()