Shamkumar commited on
Commit
94dbdc8
·
verified ·
1 Parent(s): e119a3e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from diffusers import AutoencoderKL, DiffusionPipeline
4
+ from diffusers.utils import load_image
5
+
6
+ # Load pipeline onto GPU
7
+ pipe = DiffusionPipeline.from_pretrained(
8
+ "yisol/IDM-VTON",
9
+ torch_dtype=torch.bfloat16,
10
+ device_map="cuda"
11
+ )
12
+
13
+ def process_vton(person_img, garment_img):
14
+ # Pass inputs through the model pipeline
15
+ result = pipe(
16
+ image=person_img,
17
+ garment_image=garment_img
18
+ ).images[0]
19
+ return result
20
+
21
+ # Create Gradio Interface
22
+ demo = gr.Interface(
23
+ fn=process_vton,
24
+ inputs=[
25
+ gr.Image(type="pil", label="Person Image"),
26
+ gr.Image(type="pil", label="Garment Image")
27
+ ],
28
+ outputs=gr.Image(label="Virtual Try-On Output"),
29
+ title="Virtual Try-On with IDM-VTON"
30
+ )
31
+
32
+ if __name__ == "__main__":
33
+ demo.launch()