Spaces:
Running
Running
selfitcamera
commited on
Commit
·
c51e1d5
1
Parent(s):
9739821
init
Browse files
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 📈
|
4 |
colorFrom: indigo
|
5 |
colorTo: green
|
|
|
1 |
---
|
2 |
+
title: Advanced Try On
|
3 |
emoji: 📈
|
4 |
colorFrom: indigo
|
5 |
colorTo: green
|
app.py
CHANGED
@@ -41,13 +41,9 @@ def onClick(cloth_id, pose_image, pose_id, size, request: gr.Request):
|
|
41 |
if pose_image is None:
|
42 |
return None, "no pose image found !", ""
|
43 |
|
44 |
-
# pose_id, cloth_id = pose_id['label'], cloth_id['label']
|
45 |
-
# print(pose_id, cloth_id, size, (pose_image is None), len(pose_id)>0)
|
46 |
if len(pose_id)>0:
|
47 |
res = get_result_example(cloth_id, pose_id)
|
48 |
-
# print(res)
|
49 |
assert os.path.exists(res), res
|
50 |
-
# res = cv2.imread(res)
|
51 |
return res, "Done! Use the pre-run results directly, the cloth size does not take effect ", mk_guide
|
52 |
else:
|
53 |
try:
|
@@ -67,9 +63,6 @@ def onClick(cloth_id, pose_image, pose_id, size, request: gr.Request):
|
|
67 |
if w/W>max_face_ratio or h/H>max_face_ratio:
|
68 |
return None, "Fatal Error !!! Headshot is not allowed !!! You must upload a full-body or half-body photo!!!", ""
|
69 |
|
70 |
-
if not check_region_warp(client_ip):
|
71 |
-
return None, "Failed !!! Our server is under maintenance, please try again later", ""
|
72 |
-
|
73 |
timeId = int( str(time.time()).replace(".", "") )+random.randint(1000, 9999)
|
74 |
isUpload = upload_pose_img(ApiUrl, OpenId, ApiKey, client_ip, timeId, pose_image)
|
75 |
if isUpload==0:
|
@@ -180,9 +173,6 @@ with gr.Blocks(css=css) as demo:
|
|
180 |
run_button = gr.Button(value="Run")
|
181 |
init_res = get_result_example(cloth_examples[0][0], pose_examples[0][0])
|
182 |
res_image = gr.Image(label="result image", value=None, type="filepath")
|
183 |
-
# res_image = gr.Image(label="result image", value=None, type="numpy")
|
184 |
-
# res_image = gr.Image(label="result image", value=cv2.imread(init_res),
|
185 |
-
# type="numpy")
|
186 |
MK01 = gr.Markdown()
|
187 |
|
188 |
|
|
|
41 |
if pose_image is None:
|
42 |
return None, "no pose image found !", ""
|
43 |
|
|
|
|
|
44 |
if len(pose_id)>0:
|
45 |
res = get_result_example(cloth_id, pose_id)
|
|
|
46 |
assert os.path.exists(res), res
|
|
|
47 |
return res, "Done! Use the pre-run results directly, the cloth size does not take effect ", mk_guide
|
48 |
else:
|
49 |
try:
|
|
|
63 |
if w/W>max_face_ratio or h/H>max_face_ratio:
|
64 |
return None, "Fatal Error !!! Headshot is not allowed !!! You must upload a full-body or half-body photo!!!", ""
|
65 |
|
|
|
|
|
|
|
66 |
timeId = int( str(time.time()).replace(".", "") )+random.randint(1000, 9999)
|
67 |
isUpload = upload_pose_img(ApiUrl, OpenId, ApiKey, client_ip, timeId, pose_image)
|
68 |
if isUpload==0:
|
|
|
173 |
run_button = gr.Button(value="Run")
|
174 |
init_res = get_result_example(cloth_examples[0][0], pose_examples[0][0])
|
175 |
res_image = gr.Image(label="result image", value=None, type="filepath")
|
|
|
|
|
|
|
176 |
MK01 = gr.Markdown()
|
177 |
|
178 |
|
utils.py
CHANGED
@@ -11,11 +11,11 @@ import numpy as np
|
|
11 |
import gradio as gr
|
12 |
|
13 |
|
14 |
-
ApiUrl =
|
15 |
-
OpenId =
|
16 |
-
ApiKey =
|
17 |
-
OssUrl =
|
18 |
-
Regions =
|
19 |
|
20 |
|
21 |
proj_dir = os.path.dirname(os.path.abspath(__file__))
|
@@ -83,10 +83,8 @@ def upload_pose_img(apiUrl, openId, apiKey, clientIp, timeId, img):
|
|
83 |
ret = requests.get(f"{apiUrl}/api/inf_upload", params=params)
|
84 |
res = 0
|
85 |
if ret.status_code==200:
|
86 |
-
# print(ret.json())
|
87 |
if 'data' in ret.json():
|
88 |
upload_url = ret.json()['data']
|
89 |
-
# print(upload_url, len(upload_url))
|
90 |
if 'running' in upload_url:
|
91 |
res = -1 # 存在正在进行的任务
|
92 |
elif 'no_coin' in upload_url:
|
|
|
11 |
import gradio as gr
|
12 |
|
13 |
|
14 |
+
ApiUrl = "https://selfitcamera.site/public"
|
15 |
+
OpenId = 'ovB-x639B8QwdfF7kQYS9QKdK6u8'
|
16 |
+
ApiKey = 'be0b28ba433b6245ce10b7c341f'
|
17 |
+
OssUrl = "https://selfit-deploy-1256039085.cos.accelerate.myqcloud.com/"
|
18 |
+
Regions = "IndiaKorea"
|
19 |
|
20 |
|
21 |
proj_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
83 |
ret = requests.get(f"{apiUrl}/api/inf_upload", params=params)
|
84 |
res = 0
|
85 |
if ret.status_code==200:
|
|
|
86 |
if 'data' in ret.json():
|
87 |
upload_url = ret.json()['data']
|
|
|
88 |
if 'running' in upload_url:
|
89 |
res = -1 # 存在正在进行的任务
|
90 |
elif 'no_coin' in upload_url:
|