diff --git a/run/examples/garment/00055_00.jpg b/run/examples/garment/00055_00.jpg deleted file mode 100644 index 53196e050354d14f388a13f74ae15ea07dd3139c..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/00055_00.jpg and /dev/null differ diff --git a/run/examples/garment/00126_00.jpg b/run/examples/garment/00126_00.jpg deleted file mode 100644 index bc1fa56c67dbc6b94259ef2cac10d4bf8b423451..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/00126_00.jpg and /dev/null differ diff --git a/run/examples/garment/00151_00.jpg b/run/examples/garment/00151_00.jpg deleted file mode 100644 index 09c220512f20d59a3d9ac1a8f96d9a3295c1407a..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/00151_00.jpg and /dev/null differ diff --git a/run/examples/garment/00470_00.jpg b/run/examples/garment/00470_00.jpg deleted file mode 100644 index e86ab895db2a058961f33116313f891e362ec45a..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/00470_00.jpg and /dev/null differ diff --git a/run/examples/garment/02015_00.jpg b/run/examples/garment/02015_00.jpg deleted file mode 100644 index 0c3ca4ec8a32ca8f76ac1f3529c5c99df1145fac..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/02015_00.jpg and /dev/null differ diff --git a/run/examples/garment/02305_00.jpg b/run/examples/garment/02305_00.jpg deleted file mode 100644 index ee78d9705ee96d9f8109207654ba7311f0f6ec67..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/02305_00.jpg and /dev/null differ diff --git a/run/examples/garment/03032_00.jpg b/run/examples/garment/03032_00.jpg deleted file mode 100644 index 3a5f740c111126feb67f2e0da4f2b93add554a10..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/03032_00.jpg and /dev/null differ diff --git a/run/examples/garment/03244_00.jpg b/run/examples/garment/03244_00.jpg deleted file mode 100644 index 7339871794eb50314230fda0b2276dd1dccaf0f8..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/03244_00.jpg and /dev/null differ diff --git a/run/examples/garment/04825_00.jpg b/run/examples/garment/04825_00.jpg deleted file mode 100644 index 499f0fcbb9591f599e5e7dad0b6ed9deffebd2d0..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/04825_00.jpg and /dev/null differ diff --git a/run/examples/garment/048554_1.jpg b/run/examples/garment/048554_1.jpg deleted file mode 100644 index d16eefc913f8b5bc32a94bee884ec4966034c8de..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/048554_1.jpg and /dev/null differ diff --git a/run/examples/garment/048769_1.jpg b/run/examples/garment/048769_1.jpg deleted file mode 100644 index 9940e198c97d095dd7439351ca48d0becce9bc93..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/048769_1.jpg and /dev/null differ diff --git a/run/examples/garment/049805_1.jpg b/run/examples/garment/049805_1.jpg deleted file mode 100644 index 675242162dcdf6b3b04ee8302c9e72d7ddd45514..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/049805_1.jpg and /dev/null differ diff --git a/run/examples/garment/049920_1.jpg b/run/examples/garment/049920_1.jpg deleted file mode 100644 index dd20dd9ddb63bc944941bab65c588d77d46b020b..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/049920_1.jpg and /dev/null differ diff --git a/run/examples/garment/049940_1.jpg b/run/examples/garment/049940_1.jpg deleted file mode 100644 index d5ed51c37c4ab001c661144ff1ed2bcd03982bd6..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/049940_1.jpg and /dev/null differ diff --git a/run/examples/garment/049947_1.jpg b/run/examples/garment/049947_1.jpg deleted file mode 100644 index 30e57aa828bc63bb53856273cfc2bf8c24d18c2d..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/049947_1.jpg and /dev/null differ diff --git a/run/examples/garment/049949_1.jpg b/run/examples/garment/049949_1.jpg deleted file mode 100644 index efed896e005a7eb887ac083c51cabc11f6d01960..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/049949_1.jpg and /dev/null differ diff --git a/run/examples/garment/049965_1.jpg b/run/examples/garment/049965_1.jpg deleted file mode 100644 index f6b32244af23aedb43382939df1221f8bf98d3de..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/049965_1.jpg and /dev/null differ diff --git a/run/examples/garment/050002_1.jpg b/run/examples/garment/050002_1.jpg deleted file mode 100644 index 85e70a2ecfd1192427b7403ee1dde6af3283caff..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/050002_1.jpg and /dev/null differ diff --git a/run/examples/garment/050105_1.jpg b/run/examples/garment/050105_1.jpg deleted file mode 100644 index d2a6d36f39f2cc7437b804bdc19e27f27700c8dc..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/050105_1.jpg and /dev/null differ diff --git a/run/examples/garment/050181_1.jpg b/run/examples/garment/050181_1.jpg deleted file mode 100644 index 735326e9da202b90b12728b3e33051969fe41f21..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/050181_1.jpg and /dev/null differ diff --git a/run/examples/garment/050191_1.jpg b/run/examples/garment/050191_1.jpg deleted file mode 100644 index b1cb93f85293b48f7ae460d9e4f857edb022a631..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/050191_1.jpg and /dev/null differ diff --git a/run/examples/garment/051412_1.jpg b/run/examples/garment/051412_1.jpg deleted file mode 100644 index bc6d205e5f6b62b431da24705a62dfd5f39dbaf9..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/051412_1.jpg and /dev/null differ diff --git a/run/examples/garment/051473_1.jpg b/run/examples/garment/051473_1.jpg deleted file mode 100644 index 1ea84d329eae1b249a0c32fef1ed568f6aa3a6d3..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/051473_1.jpg and /dev/null differ diff --git a/run/examples/garment/051515_1.jpg b/run/examples/garment/051515_1.jpg deleted file mode 100644 index 310db30825d66f46659660a3491ede213961a37c..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/051515_1.jpg and /dev/null differ diff --git a/run/examples/garment/051517_1.jpg b/run/examples/garment/051517_1.jpg deleted file mode 100644 index 8ce20dfdfcc3df213ff92302b302f8cbadfa19e4..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/051517_1.jpg and /dev/null differ diff --git a/run/examples/garment/051827_1.jpg b/run/examples/garment/051827_1.jpg deleted file mode 100644 index b29e53a6e8b23f6af75c9b819548f066b441cd0b..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/051827_1.jpg and /dev/null differ diff --git a/run/examples/garment/051946_1.jpg b/run/examples/garment/051946_1.jpg deleted file mode 100644 index 1f9f74062dc58ec1523820e10b66d5ab19e037dd..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/051946_1.jpg and /dev/null differ diff --git a/run/examples/garment/051988_1.jpg b/run/examples/garment/051988_1.jpg deleted file mode 100644 index 806556012ddefe4f376ab7c4ebcb663b74654a66..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/051988_1.jpg and /dev/null differ diff --git a/run/examples/garment/051991_1.jpg b/run/examples/garment/051991_1.jpg deleted file mode 100644 index ba176b669c1f612c7215b4d437471a03f41d5c3e..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/051991_1.jpg and /dev/null differ diff --git a/run/examples/garment/051998_1.jpg b/run/examples/garment/051998_1.jpg deleted file mode 100644 index 5e66de02e5094f7f8963635f94bd784f782118ec..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/051998_1.jpg and /dev/null differ diff --git a/run/examples/garment/052234_1.jpg b/run/examples/garment/052234_1.jpg deleted file mode 100644 index aab4a0aef46576aba61bef1cb159e687dcf7fc9e..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/052234_1.jpg and /dev/null differ diff --git a/run/examples/garment/053290_1.jpg b/run/examples/garment/053290_1.jpg deleted file mode 100644 index dd8be16ebaac4e268d96781996778ccd2ec078bf..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/053290_1.jpg and /dev/null differ diff --git a/run/examples/garment/053319_1.jpg b/run/examples/garment/053319_1.jpg deleted file mode 100644 index 12a4b00af7ea8c02d6206e28b9b3c8fd2af87c57..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/053319_1.jpg and /dev/null differ diff --git a/run/examples/garment/053742_1.jpg b/run/examples/garment/053742_1.jpg deleted file mode 100644 index c6a45735eba422a57c7304c2656ced165b815787..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/053742_1.jpg and /dev/null differ diff --git a/run/examples/garment/053744_1.jpg b/run/examples/garment/053744_1.jpg deleted file mode 100644 index d8add13e28879fb9c42a6c4edd594cbf63efd239..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/053744_1.jpg and /dev/null differ diff --git a/run/examples/garment/053786_1.jpg b/run/examples/garment/053786_1.jpg deleted file mode 100644 index 110329c1d2feac8da13c9b2b3771f3eab5bea254..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/053786_1.jpg and /dev/null differ diff --git a/run/examples/garment/053790_1.jpg b/run/examples/garment/053790_1.jpg deleted file mode 100644 index e10a40ae9e7cb42059622d33d5dd1068883071ba..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/053790_1.jpg and /dev/null differ diff --git a/run/examples/garment/06123_00.jpg b/run/examples/garment/06123_00.jpg deleted file mode 100644 index 4b9d954a437e6d2fa231b79e151eeb273d4ff30b..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/06123_00.jpg and /dev/null differ diff --git a/run/examples/garment/07382_00.jpg b/run/examples/garment/07382_00.jpg deleted file mode 100644 index 1335c51ca18c58d135d2eb0af74d4b63438a5543..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/07382_00.jpg and /dev/null differ diff --git a/run/examples/garment/07764_00.jpg b/run/examples/garment/07764_00.jpg deleted file mode 100644 index b2d7395b21d8cfc5d02e1139babcd05990952f2e..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/07764_00.jpg and /dev/null differ diff --git a/run/examples/garment/10297_00.jpg b/run/examples/garment/10297_00.jpg deleted file mode 100644 index 8dd11fb83f6da37ebf0ac48bc90ff461568bebf2..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/10297_00.jpg and /dev/null differ diff --git a/run/examples/garment/12562_00.jpg b/run/examples/garment/12562_00.jpg deleted file mode 100644 index 1e507b2caf4d056b92aa672509546b5a37bb2d0d..0000000000000000000000000000000000000000 Binary files a/run/examples/garment/12562_00.jpg and /dev/null differ diff --git a/run/examples/model/01008_00.jpg b/run/examples/model/01008_00.jpg deleted file mode 100644 index 7589e7c53d08ffc48230b2260658dec2e0f42373..0000000000000000000000000000000000000000 Binary files a/run/examples/model/01008_00.jpg and /dev/null differ diff --git a/run/examples/model/01861_00.jpg b/run/examples/model/01861_00.jpg deleted file mode 100644 index 4fb32773e3712a30dd9f8d842f7a66be4c352a1f..0000000000000000000000000000000000000000 Binary files a/run/examples/model/01861_00.jpg and /dev/null differ diff --git a/run/examples/model/02849_00.jpg b/run/examples/model/02849_00.jpg deleted file mode 100644 index 0e720ca1677c99f6148b8b64aa5c54448a232dfa..0000000000000000000000000000000000000000 Binary files a/run/examples/model/02849_00.jpg and /dev/null differ diff --git a/run/examples/model/049205_0.jpg b/run/examples/model/049205_0.jpg deleted file mode 100644 index a9fef6281fc5e795995b1de89648ca476e7b081e..0000000000000000000000000000000000000000 Binary files a/run/examples/model/049205_0.jpg and /dev/null differ diff --git a/run/examples/model/049447_0.jpg b/run/examples/model/049447_0.jpg deleted file mode 100644 index 9775a242f9d250635dbfba6d3704608e54520ac0..0000000000000000000000000000000000000000 Binary files a/run/examples/model/049447_0.jpg and /dev/null differ diff --git a/run/examples/model/049713_0.jpg b/run/examples/model/049713_0.jpg deleted file mode 100644 index 71732c42ad61062776df84dcc6febdaaead790ef..0000000000000000000000000000000000000000 Binary files a/run/examples/model/049713_0.jpg and /dev/null differ diff --git a/run/examples/model/051482_0.jpg b/run/examples/model/051482_0.jpg deleted file mode 100644 index 7aefbf09bc4694234ba67eccbe94be07c3dbd23f..0000000000000000000000000000000000000000 Binary files a/run/examples/model/051482_0.jpg and /dev/null differ diff --git a/run/examples/model/051918_0.jpg b/run/examples/model/051918_0.jpg deleted file mode 100644 index 1c5872fe3ae5132979413be101d768d519724d3e..0000000000000000000000000000000000000000 Binary files a/run/examples/model/051918_0.jpg and /dev/null differ diff --git a/run/examples/model/051962_0.jpg b/run/examples/model/051962_0.jpg deleted file mode 100644 index 0f365ff5ec25aa3f317b8d5c2ed80832e62248ad..0000000000000000000000000000000000000000 Binary files a/run/examples/model/051962_0.jpg and /dev/null differ diff --git a/run/examples/model/052472_0.jpg b/run/examples/model/052472_0.jpg deleted file mode 100644 index 6d9b4b089119cc26ed7a91873c390c264d71cf8c..0000000000000000000000000000000000000000 Binary files a/run/examples/model/052472_0.jpg and /dev/null differ diff --git a/run/examples/model/052767_0.jpg b/run/examples/model/052767_0.jpg deleted file mode 100644 index 6f17d28d3b7ca873c71148e0922d865a24589cec..0000000000000000000000000000000000000000 Binary files a/run/examples/model/052767_0.jpg and /dev/null differ diff --git a/run/examples/model/052964_0.jpg b/run/examples/model/052964_0.jpg deleted file mode 100644 index d3746167470e2bdea9e29eb9c73953ddb338f230..0000000000000000000000000000000000000000 Binary files a/run/examples/model/052964_0.jpg and /dev/null differ diff --git a/run/examples/model/053228_0.jpg b/run/examples/model/053228_0.jpg deleted file mode 100644 index f8e598e3e531abacf1ae5b68ea41017427bbb5d1..0000000000000000000000000000000000000000 Binary files a/run/examples/model/053228_0.jpg and /dev/null differ diff --git a/run/examples/model/053514_0.jpg b/run/examples/model/053514_0.jpg deleted file mode 100644 index 265b39bbaff9dd27ef0e8cf7c7441b98da5d27b1..0000000000000000000000000000000000000000 Binary files a/run/examples/model/053514_0.jpg and /dev/null differ diff --git a/run/examples/model/053700_0.jpg b/run/examples/model/053700_0.jpg deleted file mode 100644 index 787bd7d5cee75974595d3eaa495e3dd64a5d8e86..0000000000000000000000000000000000000000 Binary files a/run/examples/model/053700_0.jpg and /dev/null differ diff --git a/run/examples/model/05997_00.jpg b/run/examples/model/05997_00.jpg deleted file mode 100644 index 78e7082ce6ea010ccb67b098ac36212204df5841..0000000000000000000000000000000000000000 Binary files a/run/examples/model/05997_00.jpg and /dev/null differ diff --git a/run/examples/model/07966_00.jpg b/run/examples/model/07966_00.jpg deleted file mode 100644 index 98641cc9d7cda327c8b2e76590547c4a9ad74da4..0000000000000000000000000000000000000000 Binary files a/run/examples/model/07966_00.jpg and /dev/null differ diff --git a/run/examples/model/09597_00.jpg b/run/examples/model/09597_00.jpg deleted file mode 100644 index ccb23b784bec4be979dd226494175acfcd623b76..0000000000000000000000000000000000000000 Binary files a/run/examples/model/09597_00.jpg and /dev/null differ diff --git a/run/examples/model/14627_00.jpg b/run/examples/model/14627_00.jpg deleted file mode 100644 index d4eb9ea3ded36bf044200dacc86530b877d731fe..0000000000000000000000000000000000000000 Binary files a/run/examples/model/14627_00.jpg and /dev/null differ diff --git a/run/examples/model/model_1.png b/run/examples/model/model_1.png deleted file mode 100644 index 289c74ee0eba261e946e3f558ec6388e92b0c447..0000000000000000000000000000000000000000 Binary files a/run/examples/model/model_1.png and /dev/null differ diff --git a/run/examples/model/model_2.png b/run/examples/model/model_2.png deleted file mode 100644 index e1e148ef8501f1506978c5a76505f8e161cba9cb..0000000000000000000000000000000000000000 Binary files a/run/examples/model/model_2.png and /dev/null differ diff --git a/run/examples/model/model_3.png b/run/examples/model/model_3.png deleted file mode 100644 index 0292068215005240f5aca207c74528cec261b9cc..0000000000000000000000000000000000000000 Binary files a/run/examples/model/model_3.png and /dev/null differ diff --git a/run/examples/model/model_4.png b/run/examples/model/model_4.png deleted file mode 100644 index 8503bdd884ae04767202ff5954c866e0d297a2f8..0000000000000000000000000000000000000000 Binary files a/run/examples/model/model_4.png and /dev/null differ diff --git a/run/examples/model/model_5.png b/run/examples/model/model_5.png deleted file mode 100644 index b04ebef8b9e2433d305349aad37a18a7b939ddca..0000000000000000000000000000000000000000 Binary files a/run/examples/model/model_5.png and /dev/null differ diff --git a/run/examples/model/model_6.png b/run/examples/model/model_6.png deleted file mode 100644 index be198d5188ac3e60ff2dd18304c2307a1ed70366..0000000000000000000000000000000000000000 Binary files a/run/examples/model/model_6.png and /dev/null differ diff --git a/run/examples/model/model_7.png b/run/examples/model/model_7.png deleted file mode 100644 index 82811b2d49cd88ba8cfee9ef9eae456582aad04f..0000000000000000000000000000000000000000 Binary files a/run/examples/model/model_7.png and /dev/null differ diff --git a/run/examples/model/model_8.png b/run/examples/model/model_8.png deleted file mode 100644 index a11a4177474c1a238bf10a9d9faedb5e6dae91ae..0000000000000000000000000000000000000000 Binary files a/run/examples/model/model_8.png and /dev/null differ diff --git a/run/examples/model/model_9.png b/run/examples/model/model_9.png deleted file mode 100644 index 7e8124a93d9fa58d4cef0373fcd71fbe77c40a97..0000000000000000000000000000000000000000 Binary files a/run/examples/model/model_9.png and /dev/null differ diff --git a/run/gradio_ootd.py b/run/gradio_ootd.py deleted file mode 100644 index 40f01d1d0e77c21ebcce45526b807a10bcc81d42..0000000000000000000000000000000000000000 --- a/run/gradio_ootd.py +++ /dev/null @@ -1,261 +0,0 @@ -import gradio as gr -import os -from pathlib import Path -import sys -import torch -from PIL import Image, ImageOps - -from utils_ootd import get_mask_location - -PROJECT_ROOT = Path(__file__).absolute().parents[1].absolute() -sys.path.insert(0, str(PROJECT_ROOT)) - -from preprocess.openpose.run_openpose import OpenPose -from preprocess.humanparsing.run_parsing import Parsing -from ootd.inference_ootd_hd import OOTDiffusionHD -from ootd.inference_ootd_dc import OOTDiffusionDC - -import spaces - - -openpose_model_hd = OpenPose(0) -parsing_model_hd = Parsing(0) -ootd_model_hd = OOTDiffusionHD(0) - -openpose_model_dc = OpenPose(1) -parsing_model_dc = Parsing(1) -ootd_model_dc = OOTDiffusionDC(1) - - -category_dict = ['upperbody', 'lowerbody', 'dress'] -category_dict_utils = ['upper_body', 'lower_body', 'dresses'] - -example_path = os.path.join(os.path.dirname(__file__), 'examples') -model_hd = os.path.join(example_path, 'model/model_1.png') -garment_hd = os.path.join(example_path, 'garment/03244_00.jpg') -model_dc = os.path.join(example_path, 'model/model_8.png') -garment_dc = os.path.join(example_path, 'garment/048554_1.jpg') - -@spaces.GPU -def process_hd(vton_img, garm_img, n_samples, n_steps, image_scale, seed): - model_type = 'hd' - category = 0 # 0:upperbody; 1:lowerbody; 2:dress - - with torch.no_grad(): - garm_img = Image.open(garm_img).resize((768, 1024)) - vton_img = Image.open(vton_img).resize((768, 1024)) - keypoints = openpose_model_hd(vton_img.resize((384, 512))) - model_parse, _ = parsing_model_hd(vton_img.resize((384, 512))) - - mask, mask_gray = get_mask_location(model_type, category_dict_utils[category], model_parse, keypoints) - mask = mask.resize((768, 1024), Image.NEAREST) - mask_gray = mask_gray.resize((768, 1024), Image.NEAREST) - - masked_vton_img = Image.composite(mask_gray, vton_img, mask) - - images = ootd_model_hd( - model_type=model_type, - category=category_dict[category], - image_garm=garm_img, - image_vton=masked_vton_img, - mask=mask, - image_ori=vton_img, - num_samples=n_samples, - num_steps=n_steps, - image_scale=image_scale, - seed=seed, - ) - - return images - -def process_dc(vton_img, garm_img, category, n_samples, n_steps, image_scale, seed): - model_type = 'dc' - if category == 'Upper-body': - category = 0 - elif category == 'Lower-body': - category = 1 - else: - category =2 - - with torch.no_grad(): - garm_img = Image.open(garm_img).resize((768, 1024)) - vton_img = Image.open(vton_img).resize((768, 1024)) - keypoints = openpose_model_dc(vton_img.resize((384, 512))) - model_parse, _ = parsing_model_dc(vton_img.resize((384, 512))) - - mask, mask_gray = get_mask_location(model_type, category_dict_utils[category], model_parse, keypoints) - mask = mask.resize((768, 1024), Image.NEAREST) - mask_gray = mask_gray.resize((768, 1024), Image.NEAREST) - - masked_vton_img = Image.composite(mask_gray, vton_img, mask) - - images = ootd_model_dc( - model_type=model_type, - category=category_dict[category], - image_garm=garm_img, - image_vton=masked_vton_img, - mask=mask, - image_ori=vton_img, - num_samples=n_samples, - num_steps=n_steps, - image_scale=image_scale, - seed=seed, - ) - - return images - - -block = gr.Blocks().queue() -with block: - with gr.Row(): - gr.Markdown("# OOTDiffusion Demo") - with gr.Row(): - gr.Markdown("## Half-body") - with gr.Row(): - gr.Markdown("***Support upper-body garments***") - with gr.Row(): - with gr.Column(): - vton_img = gr.Image(label="Model", sources='upload', type="filepath", height=384, value=model_hd) - example = gr.Examples( - inputs=vton_img, - examples_per_page=14, - examples=[ - os.path.join(example_path, 'model/model_1.png'), - os.path.join(example_path, 'model/model_2.png'), - os.path.join(example_path, 'model/model_3.png'), - os.path.join(example_path, 'model/model_4.png'), - os.path.join(example_path, 'model/model_5.png'), - os.path.join(example_path, 'model/model_6.png'), - os.path.join(example_path, 'model/model_7.png'), - os.path.join(example_path, 'model/01008_00.jpg'), - os.path.join(example_path, 'model/07966_00.jpg'), - os.path.join(example_path, 'model/05997_00.jpg'), - os.path.join(example_path, 'model/02849_00.jpg'), - os.path.join(example_path, 'model/14627_00.jpg'), - os.path.join(example_path, 'model/09597_00.jpg'), - os.path.join(example_path, 'model/01861_00.jpg'), - ]) - with gr.Column(): - garm_img = gr.Image(label="Garment", sources='upload', type="filepath", height=384, value=garment_hd) - example = gr.Examples( - inputs=garm_img, - examples_per_page=14, - examples=[ - os.path.join(example_path, 'garment/03244_00.jpg'), - os.path.join(example_path, 'garment/00126_00.jpg'), - os.path.join(example_path, 'garment/03032_00.jpg'), - os.path.join(example_path, 'garment/06123_00.jpg'), - os.path.join(example_path, 'garment/02305_00.jpg'), - os.path.join(example_path, 'garment/00055_00.jpg'), - os.path.join(example_path, 'garment/00470_00.jpg'), - os.path.join(example_path, 'garment/02015_00.jpg'), - os.path.join(example_path, 'garment/10297_00.jpg'), - os.path.join(example_path, 'garment/07382_00.jpg'), - os.path.join(example_path, 'garment/07764_00.jpg'), - os.path.join(example_path, 'garment/00151_00.jpg'), - os.path.join(example_path, 'garment/12562_00.jpg'), - os.path.join(example_path, 'garment/04825_00.jpg'), - ]) - with gr.Column(): - result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery", preview=True, scale=1) - with gr.Column(): - run_button = gr.Button(value="Run") - n_samples = gr.Slider(label="Images", minimum=1, maximum=4, value=1, step=1) - n_steps = gr.Slider(label="Steps", minimum=20, maximum=40, value=20, step=1) - # scale = gr.Slider(label="Scale", minimum=1.0, maximum=12.0, value=5.0, step=0.1) - image_scale = gr.Slider(label="Guidance scale", minimum=1.0, maximum=5.0, value=2.0, step=0.1) - seed = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, value=-1) - - ips = [vton_img, garm_img, n_samples, n_steps, image_scale, seed] - run_button.click(fn=process_hd, inputs=ips, outputs=[result_gallery]) - - - with gr.Row(): - gr.Markdown("## Full-body") - with gr.Row(): - gr.Markdown("***Support upper-body/lower-body/dresses; garment category must be paired!!!***") - with gr.Row(): - with gr.Column(): - vton_img_dc = gr.Image(label="Model", sources='upload', type="filepath", height=384, value=model_dc) - example = gr.Examples( - label="Examples (upper-body/lower-body)", - inputs=vton_img_dc, - examples_per_page=7, - examples=[ - os.path.join(example_path, 'model/model_8.png'), - os.path.join(example_path, 'model/049447_0.jpg'), - os.path.join(example_path, 'model/049713_0.jpg'), - os.path.join(example_path, 'model/051482_0.jpg'), - os.path.join(example_path, 'model/051918_0.jpg'), - os.path.join(example_path, 'model/051962_0.jpg'), - os.path.join(example_path, 'model/049205_0.jpg'), - ]) - example = gr.Examples( - label="Examples (dress)", - inputs=vton_img_dc, - examples_per_page=7, - examples=[ - os.path.join(example_path, 'model/model_9.png'), - os.path.join(example_path, 'model/052767_0.jpg'), - os.path.join(example_path, 'model/052472_0.jpg'), - os.path.join(example_path, 'model/053514_0.jpg'), - os.path.join(example_path, 'model/053228_0.jpg'), - os.path.join(example_path, 'model/052964_0.jpg'), - os.path.join(example_path, 'model/053700_0.jpg'), - ]) - with gr.Column(): - garm_img_dc = gr.Image(label="Garment", sources='upload', type="filepath", height=384, value=garment_dc) - category_dc = gr.Dropdown(label="Garment category (important option!!!)", choices=["Upper-body", "Lower-body", "Dress"], value="Upper-body") - example = gr.Examples( - label="Examples (upper-body)", - inputs=garm_img_dc, - examples_per_page=7, - examples=[ - os.path.join(example_path, 'garment/048554_1.jpg'), - os.path.join(example_path, 'garment/049920_1.jpg'), - os.path.join(example_path, 'garment/049965_1.jpg'), - os.path.join(example_path, 'garment/049949_1.jpg'), - os.path.join(example_path, 'garment/050181_1.jpg'), - os.path.join(example_path, 'garment/049805_1.jpg'), - os.path.join(example_path, 'garment/050105_1.jpg'), - ]) - example = gr.Examples( - label="Examples (lower-body)", - inputs=garm_img_dc, - examples_per_page=7, - examples=[ - os.path.join(example_path, 'garment/051827_1.jpg'), - os.path.join(example_path, 'garment/051946_1.jpg'), - os.path.join(example_path, 'garment/051473_1.jpg'), - os.path.join(example_path, 'garment/051515_1.jpg'), - os.path.join(example_path, 'garment/051517_1.jpg'), - os.path.join(example_path, 'garment/051988_1.jpg'), - os.path.join(example_path, 'garment/051412_1.jpg'), - ]) - example = gr.Examples( - label="Examples (dress)", - inputs=garm_img_dc, - examples_per_page=7, - examples=[ - os.path.join(example_path, 'garment/053290_1.jpg'), - os.path.join(example_path, 'garment/053744_1.jpg'), - os.path.join(example_path, 'garment/053742_1.jpg'), - os.path.join(example_path, 'garment/053786_1.jpg'), - os.path.join(example_path, 'garment/053790_1.jpg'), - os.path.join(example_path, 'garment/053319_1.jpg'), - os.path.join(example_path, 'garment/052234_1.jpg'), - ]) - with gr.Column(): - result_gallery_dc = gr.Gallery(label='Output', show_label=False, elem_id="gallery", preview=True, scale=1) - with gr.Column(): - run_button_dc = gr.Button(value="Run") - n_samples_dc = gr.Slider(label="Images", minimum=1, maximum=4, value=1, step=1) - n_steps_dc = gr.Slider(label="Steps", minimum=20, maximum=40, value=20, step=1) - # scale_dc = gr.Slider(label="Scale", minimum=1.0, maximum=12.0, value=5.0, step=0.1) - image_scale_dc = gr.Slider(label="Guidance scale", minimum=1.0, maximum=5.0, value=2.0, step=0.1) - seed_dc = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, value=-1) - - ips_dc = [vton_img_dc, garm_img_dc, category_dc, n_samples_dc, n_steps_dc, image_scale_dc, seed_dc] - run_button_dc.click(fn=process_dc, inputs=ips_dc, outputs=[result_gallery_dc]) - -block.launch() diff --git a/run/images_output/mask.jpg b/run/images_output/mask.jpg deleted file mode 100644 index 6ea03733f28e158355c70f9b7108b88cff0c2180..0000000000000000000000000000000000000000 Binary files a/run/images_output/mask.jpg and /dev/null differ diff --git a/run/images_output/out_hd_0.png b/run/images_output/out_hd_0.png deleted file mode 100644 index 1e89d14afced50d5d53da5f98a1955fa5c88d184..0000000000000000000000000000000000000000 Binary files a/run/images_output/out_hd_0.png and /dev/null differ diff --git a/run/images_output/out_hd_1.png b/run/images_output/out_hd_1.png deleted file mode 100644 index 1e9787518eb46f5611d2e3807427d01180bd5c4b..0000000000000000000000000000000000000000 Binary files a/run/images_output/out_hd_1.png and /dev/null differ diff --git a/run/images_output/out_hd_2.png b/run/images_output/out_hd_2.png deleted file mode 100644 index 73ab83c9714e566659cefaf78ba34ccbfc2e1fb1..0000000000000000000000000000000000000000 Binary files a/run/images_output/out_hd_2.png and /dev/null differ diff --git a/run/images_output/out_hd_3.png b/run/images_output/out_hd_3.png deleted file mode 100644 index 77022a5f1ffe3c57a32acc594bb0aa608ad3e288..0000000000000000000000000000000000000000 Binary files a/run/images_output/out_hd_3.png and /dev/null differ diff --git a/run/run_ootd.py b/run/run_ootd.py deleted file mode 100644 index 9f93ff129c491643303a0c43fbc34b531d4a9097..0000000000000000000000000000000000000000 --- a/run/run_ootd.py +++ /dev/null @@ -1,87 +0,0 @@ -from pathlib import Path -import sys -from PIL import Image -from utils_ootd import get_mask_location - -PROJECT_ROOT = Path(__file__).absolute().parents[1].absolute() -sys.path.insert(0, str(PROJECT_ROOT)) - -from preprocess.openpose.run_openpose import OpenPose -from preprocess.humanparsing.run_parsing import Parsing -from ootd.inference_ootd_hd import OOTDiffusionHD -from ootd.inference_ootd_dc import OOTDiffusionDC - - -import argparse -parser = argparse.ArgumentParser(description='run ootd') -parser.add_argument('--gpu_id', '-g', type=int, default=0, required=False) -parser.add_argument('--model_path', type=str, default="", required=True) -parser.add_argument('--cloth_path', type=str, default="", required=True) -parser.add_argument('--model_type', type=str, default="hd", required=False) -parser.add_argument('--category', '-c', type=int, default=0, required=False) -parser.add_argument('--scale', type=float, default=2.0, required=False) -parser.add_argument('--step', type=int, default=20, required=False) -parser.add_argument('--sample', type=int, default=4, required=False) -parser.add_argument('--seed', type=int, default=-1, required=False) -args = parser.parse_args() - - -openpose_model = OpenPose(args.gpu_id) -parsing_model = Parsing(args.gpu_id) - - -category_dict = ['upperbody', 'lowerbody', 'dress'] -category_dict_utils = ['upper_body', 'lower_body', 'dresses'] - -model_type = args.model_type # "hd" or "dc" -category = args.category # 0:upperbody; 1:lowerbody; 2:dress -cloth_path = args.cloth_path -model_path = args.model_path - -image_scale = args.scale -n_steps = args.step -n_samples = args.sample -seed = args.seed - -if model_type == "hd": - model = OOTDiffusionHD(args.gpu_id) -elif model_type == "dc": - model = OOTDiffusionDC(args.gpu_id) -else: - raise ValueError("model_type must be \'hd\' or \'dc\'!") - - -if __name__ == '__main__': - - if model_type == 'hd' and category != 0: - raise ValueError("model_type \'hd\' requires category == 0 (upperbody)!") - - cloth_img = Image.open(cloth_path).resize((768, 1024)) - model_img = Image.open(model_path).resize((768, 1024)) - keypoints = openpose_model(model_img.resize((384, 512))) - model_parse, _ = parsing_model(model_img.resize((384, 512))) - - mask, mask_gray = get_mask_location(model_type, category_dict_utils[category], model_parse, keypoints) - mask = mask.resize((768, 1024), Image.NEAREST) - mask_gray = mask_gray.resize((768, 1024), Image.NEAREST) - - masked_vton_img = Image.composite(mask_gray, model_img, mask) - masked_vton_img.save('./images_output/mask.jpg') - - images = model( - model_type=model_type, - category=category_dict[category], - image_garm=cloth_img, - image_vton=masked_vton_img, - mask=mask, - image_ori=model_img, - num_samples=n_samples, - num_steps=n_steps, - image_scale=image_scale, - seed=seed, - ) - - image_idx = 0 - for image in images: - image.save('./images_output/out_' + model_type + '_' + str(image_idx) + '.png') - image_idx += 1 diff --git a/run/utils_ootd.py b/run/utils_ootd.py deleted file mode 100644 index 4e45dd5d191e6ebe4d999e9fc5fabd473887e441..0000000000000000000000000000000000000000 --- a/run/utils_ootd.py +++ /dev/null @@ -1,170 +0,0 @@ -import pdb - -import numpy as np -import cv2 -from PIL import Image, ImageDraw - -label_map = { - "background": 0, - "hat": 1, - "hair": 2, - "sunglasses": 3, - "upper_clothes": 4, - "skirt": 5, - "pants": 6, - "dress": 7, - "belt": 8, - "left_shoe": 9, - "right_shoe": 10, - "head": 11, - "left_leg": 12, - "right_leg": 13, - "left_arm": 14, - "right_arm": 15, - "bag": 16, - "scarf": 17, -} - -def extend_arm_mask(wrist, elbow, scale): - wrist = elbow + scale * (wrist - elbow) - return wrist - -def hole_fill(img): - img = np.pad(img[1:-1, 1:-1], pad_width = 1, mode = 'constant', constant_values=0) - img_copy = img.copy() - mask = np.zeros((img.shape[0] + 2, img.shape[1] + 2), dtype=np.uint8) - - cv2.floodFill(img, mask, (0, 0), 255) - img_inverse = cv2.bitwise_not(img) - dst = cv2.bitwise_or(img_copy, img_inverse) - return dst - -def refine_mask(mask): - contours, hierarchy = cv2.findContours(mask.astype(np.uint8), - cv2.RETR_CCOMP, cv2.CHAIN_APPROX_TC89_L1) - area = [] - for j in range(len(contours)): - a_d = cv2.contourArea(contours[j], True) - area.append(abs(a_d)) - refine_mask = np.zeros_like(mask).astype(np.uint8) - if len(area) != 0: - i = area.index(max(area)) - cv2.drawContours(refine_mask, contours, i, color=255, thickness=-1) - - return refine_mask - -def get_mask_location(model_type, category, model_parse: Image.Image, keypoint: dict, width=384,height=512): - im_parse = model_parse.resize((width, height), Image.NEAREST) - parse_array = np.array(im_parse) - - if model_type == 'hd': - arm_width = 60 - elif model_type == 'dc': - arm_width = 45 - else: - raise ValueError("model_type must be \'hd\' or \'dc\'!") - - parse_head = (parse_array == 1).astype(np.float32) + \ - (parse_array == 3).astype(np.float32) + \ - (parse_array == 11).astype(np.float32) - - parser_mask_fixed = (parse_array == label_map["left_shoe"]).astype(np.float32) + \ - (parse_array == label_map["right_shoe"]).astype(np.float32) + \ - (parse_array == label_map["hat"]).astype(np.float32) + \ - (parse_array == label_map["sunglasses"]).astype(np.float32) + \ - (parse_array == label_map["bag"]).astype(np.float32) - - parser_mask_changeable = (parse_array == label_map["background"]).astype(np.float32) - - arms_left = (parse_array == 14).astype(np.float32) - arms_right = (parse_array == 15).astype(np.float32) - arms = arms_left + arms_right - - if category == 'dresses': - parse_mask = (parse_array == 7).astype(np.float32) + \ - (parse_array == 4).astype(np.float32) + \ - (parse_array == 5).astype(np.float32) + \ - (parse_array == 6).astype(np.float32) - - parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed)) - - elif category == 'upper_body': - parse_mask = (parse_array == 4).astype(np.float32) + (parse_array == 7).astype(np.float32) - parser_mask_fixed_lower_cloth = (parse_array == label_map["skirt"]).astype(np.float32) + \ - (parse_array == label_map["pants"]).astype(np.float32) - parser_mask_fixed += parser_mask_fixed_lower_cloth - parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed)) - elif category == 'lower_body': - parse_mask = (parse_array == 6).astype(np.float32) + \ - (parse_array == 12).astype(np.float32) + \ - (parse_array == 13).astype(np.float32) + \ - (parse_array == 5).astype(np.float32) - parser_mask_fixed += (parse_array == label_map["upper_clothes"]).astype(np.float32) + \ - (parse_array == 14).astype(np.float32) + \ - (parse_array == 15).astype(np.float32) - parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed)) - else: - raise NotImplementedError - - # Load pose points - pose_data = keypoint["pose_keypoints_2d"] - pose_data = np.array(pose_data) - pose_data = pose_data.reshape((-1, 2)) - - im_arms_left = Image.new('L', (width, height)) - im_arms_right = Image.new('L', (width, height)) - arms_draw_left = ImageDraw.Draw(im_arms_left) - arms_draw_right = ImageDraw.Draw(im_arms_right) - if category == 'dresses' or category == 'upper_body': - shoulder_right = np.multiply(tuple(pose_data[2][:2]), height / 512.0) - shoulder_left = np.multiply(tuple(pose_data[5][:2]), height / 512.0) - elbow_right = np.multiply(tuple(pose_data[3][:2]), height / 512.0) - elbow_left = np.multiply(tuple(pose_data[6][:2]), height / 512.0) - wrist_right = np.multiply(tuple(pose_data[4][:2]), height / 512.0) - wrist_left = np.multiply(tuple(pose_data[7][:2]), height / 512.0) - ARM_LINE_WIDTH = int(arm_width / 512 * height) - size_left = [shoulder_left[0] - ARM_LINE_WIDTH // 2, shoulder_left[1] - ARM_LINE_WIDTH // 2, shoulder_left[0] + ARM_LINE_WIDTH // 2, shoulder_left[1] + ARM_LINE_WIDTH // 2] - size_right = [shoulder_right[0] - ARM_LINE_WIDTH // 2, shoulder_right[1] - ARM_LINE_WIDTH // 2, shoulder_right[0] + ARM_LINE_WIDTH // 2, - shoulder_right[1] + ARM_LINE_WIDTH // 2] - - - if wrist_right[0] <= 1. and wrist_right[1] <= 1.: - im_arms_right = arms_right - else: - wrist_right = extend_arm_mask(wrist_right, elbow_right, 1.2) - arms_draw_right.line(np.concatenate((shoulder_right, elbow_right, wrist_right)).astype(np.uint16).tolist(), 'white', ARM_LINE_WIDTH, 'curve') - arms_draw_right.arc(size_right, 0, 360, 'white', ARM_LINE_WIDTH // 2) - - if wrist_left[0] <= 1. and wrist_left[1] <= 1.: - im_arms_left = arms_left - else: - wrist_left = extend_arm_mask(wrist_left, elbow_left, 1.2) - arms_draw_left.line(np.concatenate((wrist_left, elbow_left, shoulder_left)).astype(np.uint16).tolist(), 'white', ARM_LINE_WIDTH, 'curve') - arms_draw_left.arc(size_left, 0, 360, 'white', ARM_LINE_WIDTH // 2) - - hands_left = np.logical_and(np.logical_not(im_arms_left), arms_left) - hands_right = np.logical_and(np.logical_not(im_arms_right), arms_right) - parser_mask_fixed += hands_left + hands_right - - parser_mask_fixed = np.logical_or(parser_mask_fixed, parse_head) - parse_mask = cv2.dilate(parse_mask, np.ones((5, 5), np.uint16), iterations=5) - if category == 'dresses' or category == 'upper_body': - neck_mask = (parse_array == 18).astype(np.float32) - neck_mask = cv2.dilate(neck_mask, np.ones((5, 5), np.uint16), iterations=1) - neck_mask = np.logical_and(neck_mask, np.logical_not(parse_head)) - parse_mask = np.logical_or(parse_mask, neck_mask) - arm_mask = cv2.dilate(np.logical_or(im_arms_left, im_arms_right).astype('float32'), np.ones((5, 5), np.uint16), iterations=4) - parse_mask += np.logical_or(parse_mask, arm_mask) - - parse_mask = np.logical_and(parser_mask_changeable, np.logical_not(parse_mask)) - - parse_mask_total = np.logical_or(parse_mask, parser_mask_fixed) - inpaint_mask = 1 - parse_mask_total - img = np.where(inpaint_mask, 255, 0) - dst = hole_fill(img.astype(np.uint8)) - dst = refine_mask(dst) - inpaint_mask = dst / 255 * 1 - mask = Image.fromarray(inpaint_mask.astype(np.uint8) * 255) - mask_gray = Image.fromarray(inpaint_mask.astype(np.uint8) * 127) - - return mask, mask_gray