Download app.py from DAM222222/TIENDA: direct link, hf CLI and curl.
- Browser
- Download file 999 Bytes
-
https://huggingface.co/DAM222222/TIENDA/resolve/main/app.py
- Command line
-
hf download hf://DAM222222/TIENDA/app.py
-
curl -L -o app.py https://huggingface.co/DAM222222/TIENDA/resolve/main/app.py
999 Bytes
| import gradio as gr | |
| from diffusers import StableDiffusionInpaintPipeline | |
| import torch | |
| from PIL import Image | |
| pipe = StableDiffusionInpaintPipeline.from_pretrained( | |
| "runwayml/stable-diffusion-inpainting", | |
| torch_dtype=torch.float32 | |
| ) | |
| pipe = pipe.to("cpu") | |
| def try_on(person_img, cloth_img): | |
| person = person_img.resize((512, 512)) | |
| mask = Image.new("L", (512, 512), 0) | |
| for x in range(150, 360): | |
| for y in range(150, 400): | |
| mask.putpixel((x, y), 255) | |
| prompt = "a person wearing a t-shirt, realistic clothing fit" | |
| result = pipe( | |
| prompt=prompt, | |
| image=person, | |
| mask_image=mask | |
| ).images[0] | |
| return result | |
| demo = gr.Interface( | |
| fn=try_on, | |
| inputs=[ | |
| gr.Image(type="pil", label="Foto de la persona"), | |
| gr.Image(type="pil", label="Imagen del polo") | |
| ], | |
| outputs=gr.Image(type="pil", label="Resultado"), | |
| title="Virtual Try-On", | |
| description="Sube una foto y prueba un polo con IA" | |
| ) | |
| demo.launch() |