Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ import requests
4
+ from io import BytesIO
5
+
6
+ def try_on(user_image, clothing_choice):
7
+ clothing_urls = {
8
+ "Red Dress": "https://i.ibb.co/S3ddkZq/red-dress.png",
9
+ "Moroccan Caftan": "https://i.ibb.co/xhZ4m6W/caftan.png",
10
+ "Black Jacket": "https://i.ibb.co/pKRCsm2/jacket.png"
11
+ }
12
+
13
+ response = requests.get(clothing_urls[clothing_choice])
14
+ clothing_img = Image.open(BytesIO(response.content)).convert("RGBA")
15
+
16
+ user_img = user_image.convert("RGBA")
17
+ clothing_img = clothing_img.resize(user_img.size)
18
+ blended = Image.alpha_composite(user_img, clothing_img)
19
+ return blended
20
+
21
+ demo = gr.Interface(
22
+ fn=try_on,
23
+ inputs=[
24
+ gr.Image(type="pil", label="📷 ارفع صورتك"),
25
+ gr.Radio(["Red Dress", "Moroccan Caftan", "Black Jacket"], label="👗 اختر اللباس")
26
+ ],
27
+ outputs=gr.Image(type="pil", label="📸 النتيجة"),
28
+ title="🧥 تجربة اللباس الافتراضي",
29
+ description="جرب لباساً افتراضياً على صورتك"
30
+ )
31
+
32
+ demo.launch()