Shahin's picture

Shahin

Shahinarshad
1 5

AI & ML interests

import gradio as gr from PIL import Image import uuid def tryon(person_img, cloth_img): if person_img is None or cloth_img is None: return None person_img = person_img.convert("RGBA") cloth_img = cloth_img.convert("RGBA") # resize لباس حدود نصف عرض تصویر شخص scale = person_img.width // 2 cloth_img = cloth_img.resize( (scale, int(scale * cloth_img.height / cloth_img.width)) ) # قرار دادن لباس وسط تصویر (بالای بدن) x = (person_img.width - cloth_img.width) // 2 y = person_img.height // 3 person_img.paste(cloth_img, (x, y), cloth_img) # ذخیره تصویر نهایی با نام تصادفی out_path = f"result_{uuid.uuid4().hex}.png" person_img.save(out_path) return person_img iface = gr.Interface( fn=tryon, inputs=[ gr.Image(type="pil", label="Upload Person Image"), gr.Image(type="pil", label="Upload Clothing Image") ], outputs=gr.Image(type="pil", label="Result"), title="Free Safe Virtual Try-On", description="Upload your own photo and a clothing image. This demo overlays the clothing onto the person image safely.", ) iface.launch()

Organizations

hasan arshad's profile picture