echoece commited on
Commit
693f219
·
verified ·
1 Parent(s): 547aba8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionPipeline
3
+ import torch
4
+
5
+ # ⚠️ You can replace this with any try-on model, e.g. akhaliq/TryOnDiffusion
6
+ model_id = "akhaliq/TryOnDiffusion"
7
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
8
+ pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
9
+
10
+ def try_on(person_img, cloth_img):
11
+ # Minimal demo — replace with model-specific inference
12
+ prompt = f"A photo of this person wearing the clothes shown."
13
+ images = pipe(prompt, image=[person_img, cloth_img]).images
14
+ return images[0]
15
+
16
+ demo = gr.Interface(
17
+ fn=try_on,
18
+ inputs=[gr.Image(label="Person"), gr.Image(label="Clothing")],
19
+ outputs=gr.Image(label="Result"),
20
+ title="Virtual Try-On (TryOnDiffusion)",
21
+ description="Upload a full-body photo and a clothing item to see a virtual try-on result."
22
+ )
23
+
24
+ if __name__ == "__main__":
25
+ demo.launch()