import gradio as gr from PIL import Image import requests from io import BytesIO def try_on(user_image, clothing_choice): clothing_urls = { "Red Dress": "https://i.ibb.co/S3ddkZq/red-dress.png", "Moroccan Caftan": "https://i.ibb.co/xhZ4m6W/caftan.png", "Black Jacket": "https://i.ibb.co/pKRCsm2/jacket.png" } response = requests.get(clothing_urls[clothing_choice]) clothing_img = Image.open(BytesIO(response.content)).convert("RGBA") user_img = user_image.convert("RGBA") clothing_img = clothing_img.resize(user_img.size) blended = Image.alpha_composite(user_img, clothing_img) return blended demo = gr.Interface( fn=try_on, inputs=[ gr.Image(type="pil", label="📷 ارفع صورتك"), gr.Radio(["Red Dress", "Moroccan Caftan", "Black Jacket"], label="👗 اختر اللباس") ], outputs=gr.Image(type="pil", label="📸 النتيجة"), title="🧥 تجربة اللباس الافتراضي", description="جرب لباساً افتراضياً على صورتك" ) demo.launch()