diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3b6eefbc0bcd68b15e1f325f0c0cb98dbf90f1e9 Binary files /dev/null and b/.DS_Store differ diff --git a/Datas/.DS_Store b/Datas/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d6807b658384b27778daadbfbad1d097c26c4955 Binary files /dev/null and b/Datas/.DS_Store differ diff --git a/Datas/ClothImgs/.DS_Store b/Datas/ClothImgs/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ee4b0345156da97ec7d8091ee39e25bea6f9f4a6 Binary files /dev/null and b/Datas/ClothImgs/.DS_Store differ diff --git a/Datas/ClothImgs/209.jpg b/Datas/ClothImgs/209.jpg deleted file mode 100644 index 0354564f8512be2bcdb2337c7d949f318c3fe0c7..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/209.jpg and /dev/null differ diff --git a/Datas/ClothImgs/211.jpg b/Datas/ClothImgs/211.jpg deleted file mode 100644 index 647d4d819d837c640d1a902deda743676ead64fa..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/211.jpg and /dev/null differ diff --git a/Datas/ClothImgs/214.jpg b/Datas/ClothImgs/214.jpg deleted file mode 100644 index 0bc991d5ef7b8bf936392aca7a51d40de040ef1d..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/214.jpg and /dev/null differ diff --git a/Datas/ClothImgs/216.jpg b/Datas/ClothImgs/216.jpg deleted file mode 100644 index 5eeb49547c129b406150ee7703d525e88d96298b..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/216.jpg and /dev/null differ diff --git a/Datas/ClothImgs/217.jpg b/Datas/ClothImgs/217.jpg deleted file mode 100644 index a8a23a5fa8ae949e1fd1a69521b28da920cd733a..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/217.jpg and /dev/null differ diff --git a/Datas/ClothImgs/225.jpg b/Datas/ClothImgs/225.jpg deleted file mode 100644 index 79b94e61202a2f4d2a8fe8ea3bbd5349c90c906f..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/225.jpg and /dev/null differ diff --git a/Datas/ClothImgs/226.jpg b/Datas/ClothImgs/226.jpg deleted file mode 100644 index f040bab8efaf93327c83c220cc8d67af5281523a..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/226.jpg and /dev/null differ diff --git a/Datas/ClothImgs/230.jpg b/Datas/ClothImgs/230.jpg deleted file mode 100644 index 6b5e074fdead254db365a8b3a9649389376a81d7..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/230.jpg and /dev/null differ diff --git a/Datas/ClothImgs/231.jpg b/Datas/ClothImgs/231.jpg deleted file mode 100644 index acd524fb5494698b6120c7e708e2d69deef5c746..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/231.jpg and /dev/null differ diff --git a/Datas/ClothImgs/232.jpg b/Datas/ClothImgs/232.jpg deleted file mode 100644 index c7cb6f9b0abd66ab0dee9d29b076a479ca3440b5..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/232.jpg and /dev/null differ diff --git a/Datas/ClothImgs/233.jpg b/Datas/ClothImgs/233.jpg deleted file mode 100644 index 1b96a54dd2d169ef82ba6e415dff74049b02edca..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/233.jpg and /dev/null differ diff --git a/Datas/ClothImgs/234.jpg b/Datas/ClothImgs/234.jpg deleted file mode 100644 index e497016fc00cfd782ce93f418007b4aa5a52fd84..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/234.jpg and /dev/null differ diff --git a/Datas/ClothImgs/235.jpg b/Datas/ClothImgs/235.jpg deleted file mode 100644 index eff034818b9a94d14ea71e1e92a18835b609337f..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/235.jpg and /dev/null differ diff --git a/Datas/ClothImgs/238.jpg b/Datas/ClothImgs/238.jpg deleted file mode 100644 index e6e792d9a9cc0bf8d36eeb31a1d1a3f517727729..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/238.jpg and /dev/null differ diff --git a/Datas/ClothImgs/250.jpg b/Datas/ClothImgs/250.jpg deleted file mode 100644 index 66b44d626a267649679699ca1544b9c10d62fd1e..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/250.jpg and /dev/null differ diff --git a/Datas/ClothImgs/251.jpg b/Datas/ClothImgs/251.jpg deleted file mode 100644 index df1edffc7892fc5977e987f197127faf02e8162f..0000000000000000000000000000000000000000 Binary files a/Datas/ClothImgs/251.jpg and /dev/null differ diff --git a/Datas/ClothImgs/423.jpg b/Datas/ClothImgs/423.jpg new file mode 100644 index 0000000000000000000000000000000000000000..37824bcd2890bc199b6faa3725c18af8820e6eee Binary files /dev/null and b/Datas/ClothImgs/423.jpg differ diff --git a/Datas/ClothImgs/424.jpg b/Datas/ClothImgs/424.jpg new file mode 100644 index 0000000000000000000000000000000000000000..52a174b1b17414fab8eaf5779e2ff83220d7da18 Binary files /dev/null and b/Datas/ClothImgs/424.jpg differ diff --git a/Datas/ClothImgs/425.jpg b/Datas/ClothImgs/425.jpg new file mode 100644 index 0000000000000000000000000000000000000000..73d5007d67292eb1a9be1bdca06569e6267bf85a Binary files /dev/null and b/Datas/ClothImgs/425.jpg differ diff --git a/Datas/ClothImgs/426.jpg b/Datas/ClothImgs/426.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1ac1bac9d554fa549d2aaff7c8c9087b1a0a5ae3 Binary files /dev/null and b/Datas/ClothImgs/426.jpg differ diff --git a/Datas/ClothImgs/427.jpg b/Datas/ClothImgs/427.jpg new file mode 100644 index 0000000000000000000000000000000000000000..55b1212d011a9ab12f226849053d8f83fdd378d0 Binary files /dev/null and b/Datas/ClothImgs/427.jpg differ diff --git a/Datas/ClothImgs/428.jpg b/Datas/ClothImgs/428.jpg new file mode 100644 index 0000000000000000000000000000000000000000..646d82995b49ae680eb20efa54ae826f27da490b Binary files /dev/null and b/Datas/ClothImgs/428.jpg differ diff --git a/Datas/ClothImgs/429.jpg b/Datas/ClothImgs/429.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9d22d8acb27144ff8851f121d5c08c4cc7643abd Binary files /dev/null and b/Datas/ClothImgs/429.jpg differ diff --git a/Datas/ClothImgs/430.jpg b/Datas/ClothImgs/430.jpg new file mode 100644 index 0000000000000000000000000000000000000000..07f297f5cf358e8b8aa74b7d244aac9322e39b25 Binary files /dev/null and b/Datas/ClothImgs/430.jpg differ diff --git a/Datas/ClothImgs/431.jpg b/Datas/ClothImgs/431.jpg new file mode 100644 index 0000000000000000000000000000000000000000..bc889ac016792a9bfa3394ee2098d4733d278ad6 Binary files /dev/null and b/Datas/ClothImgs/431.jpg differ diff --git a/Datas/ClothImgs/432.jpg b/Datas/ClothImgs/432.jpg new file mode 100644 index 0000000000000000000000000000000000000000..68d05da9cbfea192db6165742252f5ccfe412b1b Binary files /dev/null and b/Datas/ClothImgs/432.jpg differ diff --git a/Datas/ClothImgs/446.jpg b/Datas/ClothImgs/446.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e275bbfb77062455426cf2b6acd96158ed968d68 Binary files /dev/null and b/Datas/ClothImgs/446.jpg differ diff --git a/Datas/ClothImgs/447.jpg b/Datas/ClothImgs/447.jpg new file mode 100644 index 0000000000000000000000000000000000000000..68d51b85228bc19347922ae16d0e55df609561ea Binary files /dev/null and b/Datas/ClothImgs/447.jpg differ diff --git a/Datas/ClothImgs/448.jpg b/Datas/ClothImgs/448.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9fed74caaa2c0eded0dfaeaf4220f9ec1d4393fc Binary files /dev/null and b/Datas/ClothImgs/448.jpg differ diff --git a/Datas/ClothImgs/449.jpg b/Datas/ClothImgs/449.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ece3cf31bc30eb5cf5c6c6a5fb284d2458823400 Binary files /dev/null and b/Datas/ClothImgs/449.jpg differ diff --git a/Datas/ClothImgs/450.jpg b/Datas/ClothImgs/450.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d8adc7997a5b928ffcce5cd6ea417a7f0a33424b Binary files /dev/null and b/Datas/ClothImgs/450.jpg differ diff --git a/Datas/ClothImgs/451.jpg b/Datas/ClothImgs/451.jpg new file mode 100644 index 0000000000000000000000000000000000000000..30f2201592ad9f1b00aedb15ef2cd002b8d6cfc5 Binary files /dev/null and b/Datas/ClothImgs/451.jpg differ diff --git a/Datas/ClothImgs/452.jpg b/Datas/ClothImgs/452.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7a548cec2c4febba689f62f8bf1096f1d09c5633 Binary files /dev/null and b/Datas/ClothImgs/452.jpg differ diff --git a/Datas/ClothImgs/453.jpg b/Datas/ClothImgs/453.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9afd8f8870c5a029db2fb03319dd9e3dd31a326b Binary files /dev/null and b/Datas/ClothImgs/453.jpg differ diff --git a/Datas/ClothImgs/454.jpg b/Datas/ClothImgs/454.jpg new file mode 100644 index 0000000000000000000000000000000000000000..09f189da97669dff3da8ba30705647277fde133f Binary files /dev/null and b/Datas/ClothImgs/454.jpg differ diff --git a/Datas/ClothImgs/455.jpg b/Datas/ClothImgs/455.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c7badea9410361a307b4a968c4fd3671696f29bb Binary files /dev/null and b/Datas/ClothImgs/455.jpg differ diff --git a/Datas/ClothImgs/464.jpg b/Datas/ClothImgs/464.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d3431d66bd71a3c20bb2249beffe40bd3ba8d58e Binary files /dev/null and b/Datas/ClothImgs/464.jpg differ diff --git a/Datas/ClothImgs/466.jpg b/Datas/ClothImgs/466.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2aeaa68a348e6d331d0f9d9637b5b51e68434a70 Binary files /dev/null and b/Datas/ClothImgs/466.jpg differ diff --git a/Datas/ClothImgs/467.jpg b/Datas/ClothImgs/467.jpg new file mode 100644 index 0000000000000000000000000000000000000000..bc889ac016792a9bfa3394ee2098d4733d278ad6 Binary files /dev/null and b/Datas/ClothImgs/467.jpg differ diff --git a/Datas/ClothImgs/472.jpg b/Datas/ClothImgs/472.jpg new file mode 100644 index 0000000000000000000000000000000000000000..141f8be9a833ee0c187d191467e434036719b486 Binary files /dev/null and b/Datas/ClothImgs/472.jpg differ diff --git a/Datas/ClothImgs/473.jpg b/Datas/ClothImgs/473.jpg new file mode 100644 index 0000000000000000000000000000000000000000..858c605667c20fe901866a47f326389d7657502d Binary files /dev/null and b/Datas/ClothImgs/473.jpg differ diff --git a/Datas/ClothImgs/479.jpg b/Datas/ClothImgs/479.jpg new file mode 100644 index 0000000000000000000000000000000000000000..abe803c64630473906d76db0c3cf90177ede22ec Binary files /dev/null and b/Datas/ClothImgs/479.jpg differ diff --git a/Datas/ClothImgs/481.jpg b/Datas/ClothImgs/481.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d7d95aa780559bff7a06bab05486ad014f73f356 Binary files /dev/null and b/Datas/ClothImgs/481.jpg differ diff --git a/Datas/ClothImgs/482.jpg b/Datas/ClothImgs/482.jpg new file mode 100644 index 0000000000000000000000000000000000000000..76fb17ebb6980c505d4939bf234c918e529fed02 Binary files /dev/null and b/Datas/ClothImgs/482.jpg differ diff --git a/Datas/ClothImgs/486.jpg b/Datas/ClothImgs/486.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5cfe0b784355684e63419e029a83cc09c2f863db Binary files /dev/null and b/Datas/ClothImgs/486.jpg differ diff --git a/Datas/ClothImgs/494.jpg b/Datas/ClothImgs/494.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c405e4305621aeb5b521c14876e8109245ed9f09 Binary files /dev/null and b/Datas/ClothImgs/494.jpg differ diff --git a/Datas/ClothImgs/495.jpg b/Datas/ClothImgs/495.jpg new file mode 100644 index 0000000000000000000000000000000000000000..96edd478bd62ddb9ccc4c61eaf6ad1929696fd99 Binary files /dev/null and b/Datas/ClothImgs/495.jpg differ diff --git a/Datas/ClothImgs/496.jpg b/Datas/ClothImgs/496.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5c6f71b7d6c255c1346192b852b1e696b4ab967b Binary files /dev/null and b/Datas/ClothImgs/496.jpg differ diff --git a/Datas/ClothImgs/497.jpg b/Datas/ClothImgs/497.jpg new file mode 100644 index 0000000000000000000000000000000000000000..31d275f99bf4e321cc696153b3965fdfd2654692 Binary files /dev/null and b/Datas/ClothImgs/497.jpg differ diff --git a/Datas/ClothImgs/505.jpg b/Datas/ClothImgs/505.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e7aef2cce4deb26ef91d600a117e058af93fbf02 Binary files /dev/null and b/Datas/ClothImgs/505.jpg differ diff --git a/Datas/ClothImgs/507.jpg b/Datas/ClothImgs/507.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fd13cddb2d1c697cbe048b65fc840893543e9f8e Binary files /dev/null and b/Datas/ClothImgs/507.jpg differ diff --git a/Datas/ClothImgs/508.jpg b/Datas/ClothImgs/508.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9cc86521059c19672e7e288db99bf3f5f05e245c Binary files /dev/null and b/Datas/ClothImgs/508.jpg differ diff --git a/Datas/PoseImgs/.DS_Store b/Datas/PoseImgs/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4557496112ed7c1351de268cb046750d7cbacb3d Binary files /dev/null and b/Datas/PoseImgs/.DS_Store differ diff --git a/Datas/PoseImgs/26.jpg b/Datas/PoseImgs/26.jpg new file mode 100644 index 0000000000000000000000000000000000000000..913f5f9444fdc7d1a93cfa5c73a44cd0a73756a8 Binary files /dev/null and b/Datas/PoseImgs/26.jpg differ diff --git a/Datas/PoseImgs/IMG_20240410_093336.jpg b/Datas/PoseImgs/IMG_20240410_093336.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6f5d395500628889dfb91ec5a009bcb466c9be20 Binary files /dev/null and b/Datas/PoseImgs/IMG_20240410_093336.jpg differ diff --git a/Datas/PoseImgs/Screenshot_20240410_092535.jpg b/Datas/PoseImgs/Screenshot_20240410_092535.jpg new file mode 100644 index 0000000000000000000000000000000000000000..549ee4ff444742844cd07ff9f49506b3025e372b Binary files /dev/null and b/Datas/PoseImgs/Screenshot_20240410_092535.jpg differ diff --git a/Datas/PoseImgs/Screenshot_20240410_092610.jpg b/Datas/PoseImgs/Screenshot_20240410_092610.jpg new file mode 100644 index 0000000000000000000000000000000000000000..029f68ae1dbd0df624c106e9dfcd749d4004944e Binary files /dev/null and b/Datas/PoseImgs/Screenshot_20240410_092610.jpg differ diff --git a/Datas/PoseImgs/Screenshot_20240410_092646.jpg b/Datas/PoseImgs/Screenshot_20240410_092646.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b33991c785f1f21bff9789ea31ba4ad5c69f3c63 Binary files /dev/null and b/Datas/PoseImgs/Screenshot_20240410_092646.jpg differ diff --git a/Datas/PoseImgs/Screenshot_20240410_092703.jpg b/Datas/PoseImgs/Screenshot_20240410_092703.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5059713fa239266b9fb64344c055088ac6a5c9ab Binary files /dev/null and b/Datas/PoseImgs/Screenshot_20240410_092703.jpg differ diff --git a/Datas/PoseImgs/Screenshot_20240410_092739.jpg b/Datas/PoseImgs/Screenshot_20240410_092739.jpg new file mode 100644 index 0000000000000000000000000000000000000000..29b16114da28a2e65268280fa033355b009030f4 Binary files /dev/null and b/Datas/PoseImgs/Screenshot_20240410_092739.jpg differ diff --git a/Datas/PoseImgs/Screenshot_20240410_092951.jpg b/Datas/PoseImgs/Screenshot_20240410_092951.jpg new file mode 100644 index 0000000000000000000000000000000000000000..eec64bca82f23b4b81bc8b5e4b7a3d03df2009ee Binary files /dev/null and b/Datas/PoseImgs/Screenshot_20240410_092951.jpg differ diff --git a/Datas/PoseImgs/Screenshot_20240410_093030.jpg b/Datas/PoseImgs/Screenshot_20240410_093030.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ac065560583c1cd29ec518bc4bf3ea916ad35237 Binary files /dev/null and b/Datas/PoseImgs/Screenshot_20240410_093030.jpg differ diff --git a/Datas/PoseImgs/Screenshot_20240410_093050.jpg b/Datas/PoseImgs/Screenshot_20240410_093050.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5b25b4acf450571f3aed3422cd81327136bc1a0e Binary files /dev/null and b/Datas/PoseImgs/Screenshot_20240410_093050.jpg differ diff --git a/Datas/PoseImgs/Screenshot_20240410_093203.jpg b/Datas/PoseImgs/Screenshot_20240410_093203.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e086688c7ae39ed759d662b8c449166d3c5991b2 Binary files /dev/null and b/Datas/PoseImgs/Screenshot_20240410_093203.jpg differ diff --git a/Datas/PoseImgs/WechatIMG224.jpg b/Datas/PoseImgs/WechatIMG224.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c73e4e113d2594c7f1ffc7e3cc6a26bc02d2bd18 Binary files /dev/null and b/Datas/PoseImgs/WechatIMG224.jpg differ diff --git a/Datas/PoseImgs/WechatIMG264.jpg b/Datas/PoseImgs/WechatIMG264.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a1df64ed0b17bcba543d64afe949474b9b972469 Binary files /dev/null and b/Datas/PoseImgs/WechatIMG264.jpg differ diff --git a/Datas/PoseImgs/pose_sit_4.jpg b/Datas/PoseImgs/pose_sit_4.jpg deleted file mode 100644 index 78a6512c4f1745f00f006e7dfd6502ba7898fe81..0000000000000000000000000000000000000000 Binary files a/Datas/PoseImgs/pose_sit_4.jpg and /dev/null differ diff --git a/__pycache__/utils.cpython-312.pyc b/__pycache__/utils.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..200950497c101031c33de5fc8b77923aad629da0 Binary files /dev/null and b/__pycache__/utils.cpython-312.pyc differ diff --git a/app.py b/app.py index 0f1831251eff9546f86eb3e271c974dd75b46428..5814dfa710141e9083824b282353e1bff9660504 100644 --- a/app.py +++ b/app.py @@ -1,27 +1,17 @@ -from mtcnn.mtcnn import MTCNN from utils import * - cloth_examples = get_cloth_examples() pose_examples = get_pose_examples() tip1, tip2 = get_tips() -face_detector = MTCNN() # Description title = r""" -

Outfit Anyone in the Wild: Get rid of Annoying Restrictions for Virtual Try-on Task

+

Outfit Anyone in the Wild: Best Virtual Try-on Task Ever

""" description = r""" - Go to HeyBeauty for Faster and Free Try-On! 🤗 .
- -Official 🤗 Gradio demo for Outfit Anyone in the Wild: Get rid of Annoying Restrictions for Virtual Try-on Task.
-1. Clothing models are fixed in this demo, but you can create your own in our WeChat applet (for Chainese users). -2. You can upload your own pose photo, then click the run button and wait for 3~5 minutes to see the results. -3. After submitting the task, feel free to leave this page. Everytime you refresh this page, completed tasks will be displayed on the history tab (bind with your ip address). -4. Share your try-on photo with your friends and enjoy! 😊.
Test results on man01.
Test results on woman01.
Test results on woman02.
@@ -37,71 +27,71 @@ mk_guide = "If image does not display successfully after button clicked in your def onUpload(): return "" -def onClick(cloth_id, pose_image, pose_id, size, request: gr.Request): +def onClick(cloth_image, pose_image, size): if pose_image is None: + yield None, "no pose image found !", "" return None, "no pose image found !", "" + if cloth_image is None: + yield None, "no cloth image found !", "" + return None, "no cloth image found !", "" + pose_id = os.path.basename(pose_image).split(".")[0] + cloth_id = int(os.path.basename(cloth_image).split(".")[0]) if len(pose_id)>0: res = get_result_example(cloth_id, pose_id) - assert os.path.exists(res), res - return res, "Done! Use the pre-run results directly, the cloth size does not take effect ", mk_guide - else: - try: - client_ip = request.client.host - x_forwarded_for = dict(request.headers).get('x-forwarded-for') - if x_forwarded_for: - client_ip = x_forwarded_for - - faces = face_detector.detect_faces(pose_image[:,:,::-1]) - if len(faces)==0: - print(client_ip, 'faces num is 0! ', flush=True) - return None, "Fatal Error !!! No face detected !!! You must upload a human photo!!! Not clothing photo!!!", "" + print(res) + if os.path.exists(res): + yield res, "Done! Use the pre-run results directly, the cloth size does not take effect ", mk_guide + return res, "Done! Use the pre-run results directly, the cloth size does not take effect ", mk_guide + + try: + client_ip = '0' + + timeId = int( str(time.time()).replace(".", "") )+random.randint(1000, 9999) + isUpload = upload_pose_img(ApiUrl, OpenId, ApiKey, client_ip, timeId, pose_image) + if isUpload==0: + yield None, "fail to upload", "" + return None, "fail to upload", "" + elif isUpload==-1: + yield None, "There is a running task already, please wait and check the history tab. Please remember to give us a star on github, thx~", "" + return None, "There is a running task already, please wait and check the history tab. Please remember to give us a star on github, thx~", "" + + elif isUpload==-2: + yield None, "can not creat task, you have exhausted free trial quota", "" + return None, "can not creat task, you have exhausted free trial quota", "" + + taskId = publicClothSwap(ApiUrl, OpenId, ApiKey, client_ip, cloth_id, timeId, size) + if taskId==0: + yield None, "fail to public you task", "" + return None, "fail to public you task", "" + + max_try = 100 + wait_s = 1 + for i in range(max_try): + time.sleep(wait_s) + state = getInfRes(ApiUrl, OpenId, ApiKey, client_ip, timeId) + if state=='stateIs-1': + yield None, "task failed, it may be that no human was detected, or there may be illegal content, etc. ", "" + return None, "task failed, it may be that no human was detected, or there may be illegal content, etc. ", "" + elif state=='stateIs0': + yield None, "task not public success", "" + return None, "task not public success", "" + elif len(state)>20: + yield state, "task finished", "" + return state, "task finished", "" + elif (not state.startswith('stateIs')): + yield None, f"task is on processing, query {i}", "" + pass else: - x, y, w, h = faces[0]["box"] - H, W = pose_image.shape[:2] - max_face_ratio = 1/3.3 - if w/W>max_face_ratio or h/H>max_face_ratio: - return None, "Fatal Error !!! Headshot is not allowed !!! You must upload a full-body or half-body photo!!!", "" - - timeId = int( str(time.time()).replace(".", "") )+random.randint(1000, 9999) - isUpload = upload_pose_img(ApiUrl, OpenId, ApiKey, client_ip, timeId, pose_image) - if isUpload==0: - return None, "fail to upload", "" - elif isUpload==-1: - return None, "There is a running task already, please wait and check the history tab. Please remember to give us a star on github, thx~", "" - elif isUpload==-2: - return None, "can not creat task, you have exhausted free trial quota", "" - - taskId = publicClothSwap(ApiUrl, OpenId, ApiKey, client_ip, cloth_id, timeId, size) - if taskId==0: - return None, "fail to public you task", "" - - max_try = 30 - wait_s = 3 - for i in range(max_try): - time.sleep(wait_s) - state = getInfRes(ApiUrl, OpenId, ApiKey, client_ip, timeId) - if state=='stateIs-1': - return None, "task failed, it may be that no human was detected, or there may be illegal content, etc. ", "" - elif state=='stateIs0': - return None, "task not public success", "" - elif len(state)>20: - return state, "task finished", "" - elif (not state.startswith('stateIs')): - # return None, 'task is in queue, position is '+str(state) - pass - else: - return None, state, "" - return None, "task has been created successfully, you can refresh the page 5~15 mins latter, and check the following history tab", "" - except Exception as e: - print(e) - return None, "fail to create task", "" + return None, state, "" + return None, "task has been created successfully, you can refresh the page 5~15 mins latter, and check the following history tab", "" + except Exception as e: + print(e) + raise e + return None, "fail to create task", "" def onLoad(request: gr.Request): - client_ip = request.client.host - x_forwarded_for = dict(request.headers).get('x-forwarded-for') - if x_forwarded_for: - client_ip = x_forwarded_for + client_ip = '8.8.8.8' his_datas = [None for _ in range(10)] info = '' try: @@ -125,18 +115,15 @@ def onLoad(request: gr.Request): if fail_n>0: info = info+" Please upload a half/full-body human image, not just a clothing image!!!" if queue_n>0: - info = info+" Wait for 3~10 mins and refresh this page, successed results will display in the history tab at the bottom" - info = info + "Go to heybeauty for better virtual try-on ! https://heybeauty.ai/extension" - - time.sleep(3) + info = info+" Wait for 1 min and refresh this page, successed results will display in the history tab at the bottom" + except Exception as e: print(e) his_datas = his_datas + [info] return his_datas -with gr.Blocks(css=css) as demo: - # description +with gr.Blocks() as demo: gr.Markdown(title) gr.Markdown(description) @@ -147,32 +134,22 @@ with gr.Blocks(css=css) as demo: with gr.Row(): with gr.Column(): - with gr.Column(): - cloth_id = gr.Textbox(value="497", interactive=True, - label='clothId') - # cloth_image = gr.Image(sources='clipboard', type="filepath", label="", - # value=None) - # cloth_id = gr.Label(value=cloth_examples[0][0], label="Clothing 3D Model", visible=False) - # example = gr.Examples(inputs=[cloth_id, cloth_image], - # examples_per_page=3, - # examples = cloth_examples) + cloth_image = gr.Image(value=cloth_examples[0], sources='clipboard', type="filepath", label="") + example = gr.Examples(inputs=cloth_image, + examples_per_page=9, + examples=cloth_examples) with gr.Column(): - with gr.Column(): - # pose_image = gr.Image(source='upload', value=pose_examples[0][1], - # type="numpy", label="") - pose_image = gr.Image(value=None, type="numpy", label="") - pose_id = gr.Label(value=pose_examples[0][0], label="Pose Image", visible=False) - example_pose = gr.Examples(inputs=[pose_id, pose_image], - examples_per_page=3, - examples=pose_examples) - + pose_image = gr.Image(value=pose_examples[0], type="filepath", label="") + example_pose = gr.Examples(inputs=pose_image, + examples_per_page=9, + examples=pose_examples) + with gr.Column(): with gr.Column(): size_slider = gr.Slider(-2.5, 2.5, value=1, interactive=True, label="clothes size") info_text = gr.Textbox(value="", interactive=False, label='runtime information') run_button = gr.Button(value="Run") - init_res = get_result_example(cloth_id, pose_examples[0][0]) res_image = gr.Image(label="result image", value=None, type="filepath") MK01 = gr.Markdown() @@ -202,10 +179,10 @@ with gr.Blocks(css=css) as demo: his_pose_image5 = gr.HTML() his_res_image5 = gr.HTML() - run_button.click(fn=onClick, inputs=[cloth_id, pose_image, pose_id, size_slider], - outputs=[res_image, info_text, MK01], concurrency_limit=50) + run_button.click(fn=onClick, inputs=[cloth_image, pose_image, size_slider], + outputs=[res_image, info_text, MK01]) - pose_image.upload(fn=onUpload, inputs=[], outputs=[pose_id],) + pose_image.upload(fn=onUpload, inputs=[], outputs=[],) demo.load(onLoad, inputs=[], outputs=[his_pose_image1, his_res_image1, his_pose_image2, his_res_image2, his_pose_image3, his_res_image3, his_pose_image4, his_res_image4, his_pose_image5, his_res_image5, diff --git a/requirements.txt b/requirements.txt index 1addd72aa1b967a0ec84ab52193733b8eb54e360..b1714bd72d18af1905943f7f50f8e96439f2aee1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,4 @@ numpy requests gradio==3.41.2 gradio-client==0.5.0 -mtcnn -tensorflow func_timeout \ No newline at end of file diff --git a/tmp/01729224629421038.jpg b/tmp/01729224629421038.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a26a9094767ef836ec23e63f1ed5a071ef2029a3 Binary files /dev/null and b/tmp/01729224629421038.jpg differ diff --git a/tmp/01729224682161134.jpg b/tmp/01729224682161134.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a26a9094767ef836ec23e63f1ed5a071ef2029a3 Binary files /dev/null and b/tmp/01729224682161134.jpg differ diff --git a/utils.py b/utils.py index d51213aa01d40e6b15e88408ebd736e30f283173..22ce46a6061e00c570b62d8bf0d9c713b21d4e45 100644 --- a/utils.py +++ b/utils.py @@ -29,11 +29,12 @@ def get_cloth_examples(): cloth_dir = os.path.join(data_dir, 'ClothImgs') examples = [] files = sorted(os.listdir(cloth_dir)) - # files = sorted(os.listdir(cloth_dir))[::-1] for f in files: + if '.jpg' not in f and '.png' not in f: + continue cloth_id = f.split(".")[0] cloth_path = os.path.join(cloth_dir, f) - examples.append([cloth_id, cloth_path]) + examples.append(cloth_path) examples = examples[::-1] return examples @@ -41,9 +42,11 @@ def get_pose_examples(): pose_dir = os.path.join(data_dir, 'PoseImgs') examples = [] for f in os.listdir(pose_dir): + if '.jpg' not in f and '.png' not in f: + continue pose_id = f.split(".")[0] pose_path = os.path.join(pose_dir, f) - examples.append([pose_id, pose_path]) + examples.append(pose_path) return examples def get_result_example(cloth_id, pose_id): @@ -76,7 +79,8 @@ def getAllInfs(apiUrl, openId, apiKey, clientIp): def upload_pose_img(apiUrl, openId, apiKey, clientIp, timeId, img): fileName = clientIp.replace(".", "")+str(timeId)+".jpg" local_path = os.path.join(tmpFolder, fileName) - cv2.imwrite(os.path.join(tmpFolder, fileName), img[:,:,::-1]) + img = cv2.imread(img) + cv2.imwrite(os.path.join(tmpFolder, fileName), img) params = {'openId':openId, 'apiKey':apiKey, 'ipId':clientIp, 'timeId':str(timeId), 'fileName':fileName} session = requests.session() @@ -101,7 +105,7 @@ def upload_pose_img(apiUrl, openId, apiKey, clientIp, timeId, img): def publicClothSwap(apiUrl, openId, apiKey, clientIp, clothId, timeId, size): params = {'openId':openId, 'apiKey':apiKey, 'ipId':clientIp, - 'timeId':timeId, 'clothId':clothId, 'bmi':size} + 'timeId':timeId, 'clothId':int(clothId), 'bmi':size} session = requests.session() ret = requests.get(f"{apiUrl}/api/cloth_swap", params=params) if ret.status_code==200: