first commit
Browse files- .gitattributes +3 -0
- README.md +2 -2
- app.py +437 -0
- assets/examples/result_01_01.jpeg +3 -0
- assets/examples/result_04_01.jpeg +3 -0
- assets/examples/result_06_01.jpeg +3 -0
- assets/examples/result_07_01.jpeg +3 -0
- assets/human/01.png +3 -0
- assets/human/02.png +3 -0
- assets/human/03.png +3 -0
- assets/human/04.png +3 -0
- assets/human/05.jpeg +3 -0
- assets/human/06.png +3 -0
- assets/human/07.png +3 -0
- assets/human/08.png +3 -0
- assets/human/09.png +3 -0
- assets/title.html +100 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
---
|
| 2 |
title: WeShopAI Pose Generator
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.25.2
|
|
|
|
| 1 |
---
|
| 2 |
title: WeShopAI Pose Generator
|
| 3 |
+
emoji: πββοΈ
|
| 4 |
+
colorFrom: pink
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.25.2
|
app.py
ADDED
|
@@ -0,0 +1,437 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import hmac
|
| 3 |
+
import hashlib
|
| 4 |
+
import time
|
| 5 |
+
import os
|
| 6 |
+
import requests
|
| 7 |
+
from io import BytesIO
|
| 8 |
+
from PIL import Image
|
| 9 |
+
import uuid
|
| 10 |
+
|
| 11 |
+
# from dotenv import load_dotenv
|
| 12 |
+
|
| 13 |
+
# load_dotenv()
|
| 14 |
+
|
| 15 |
+
example_path = os.path.join(os.path.dirname(__file__), 'assets')
|
| 16 |
+
human_list = os.listdir(os.path.join(example_path, "human"))
|
| 17 |
+
human_list_path = [os.path.join(example_path, "human", human) for human in human_list]
|
| 18 |
+
|
| 19 |
+
base_url = os.getenv('base_url')
|
| 20 |
+
upload_image_url = os.getenv('upload_image_url')
|
| 21 |
+
create_save_task_url = os.getenv('create_save_task_url')
|
| 22 |
+
execute_task_url = os.getenv('execute_task_url')
|
| 23 |
+
query_task_url = os.getenv('query_task_url')
|
| 24 |
+
secret_key = os.getenv('secret_key')
|
| 25 |
+
app_id = os.getenv('app_id')
|
| 26 |
+
agent_version = os.getenv('agent_version')
|
| 27 |
+
agent_name = os.getenv('agent_name')
|
| 28 |
+
|
| 29 |
+
def parse_response(response):
|
| 30 |
+
data = {}
|
| 31 |
+
msg = ''
|
| 32 |
+
if response.status_code == 200:
|
| 33 |
+
try:
|
| 34 |
+
datas = response.json()
|
| 35 |
+
if datas:
|
| 36 |
+
data = datas.get("data")
|
| 37 |
+
if not data:
|
| 38 |
+
msg = datas.get("msg")
|
| 39 |
+
if not msg:
|
| 40 |
+
msg = "Field error."
|
| 41 |
+
else:
|
| 42 |
+
msg = "The parsing result is empty."
|
| 43 |
+
except Exception as e:
|
| 44 |
+
msg = f"parse error: {repr(e)}."
|
| 45 |
+
else:
|
| 46 |
+
msg = f'request error.'
|
| 47 |
+
return data, msg
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def generate_signature(key, did, timestamp):
|
| 51 |
+
data = f"{did}:{timestamp}{app_id}"
|
| 52 |
+
h = hmac.new(key.encode(), data.encode(), hashlib.sha256)
|
| 53 |
+
return h.hexdigest()
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def url_to_image(url, ip):
|
| 57 |
+
headers = {
|
| 58 |
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
| 59 |
+
'X-Forwarded-For': ip
|
| 60 |
+
}
|
| 61 |
+
try:
|
| 62 |
+
response = requests.get(url, headers=headers, timeout=30)
|
| 63 |
+
except:
|
| 64 |
+
return None
|
| 65 |
+
if response.status_code == 200:
|
| 66 |
+
img = Image.open(BytesIO(response.content))
|
| 67 |
+
return img
|
| 68 |
+
return None
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def start_task(task_id, did, ip):
|
| 72 |
+
timestamp = str(int(time.time()))
|
| 73 |
+
signature = generate_signature(
|
| 74 |
+
key=secret_key,
|
| 75 |
+
did=did,
|
| 76 |
+
timestamp=timestamp,
|
| 77 |
+
)
|
| 78 |
+
headers = {
|
| 79 |
+
'Did': did,
|
| 80 |
+
'X-Timestamp': timestamp,
|
| 81 |
+
'X-Signature': signature,
|
| 82 |
+
'X-Forwarded-For': ip,
|
| 83 |
+
'X-AppId': app_id,
|
| 84 |
+
}
|
| 85 |
+
data = {
|
| 86 |
+
"agentVersion": agent_version,
|
| 87 |
+
"agentName": agent_name,
|
| 88 |
+
"taskId": task_id,
|
| 89 |
+
"runFreeAsFallback": False
|
| 90 |
+
}
|
| 91 |
+
response = requests.post(base_url + execute_task_url, json=data, headers=headers)
|
| 92 |
+
data, msg = parse_response(response)
|
| 93 |
+
return data, msg
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def create_task(image_url, did, ip):
|
| 97 |
+
timestamp = str(int(time.time()))
|
| 98 |
+
signature = generate_signature(
|
| 99 |
+
key=secret_key,
|
| 100 |
+
did=did,
|
| 101 |
+
timestamp=timestamp,
|
| 102 |
+
)
|
| 103 |
+
headers = {
|
| 104 |
+
'Did': did,
|
| 105 |
+
'X-Timestamp': timestamp,
|
| 106 |
+
'X-Signature': signature,
|
| 107 |
+
'X-Forwarded-For': ip,
|
| 108 |
+
'X-AppId': app_id,
|
| 109 |
+
}
|
| 110 |
+
data = {
|
| 111 |
+
"agentVersion": agent_version,
|
| 112 |
+
"agentName": agent_name,
|
| 113 |
+
"image": image_url
|
| 114 |
+
}
|
| 115 |
+
response = requests.post(base_url + create_save_task_url, json=data, headers=headers)
|
| 116 |
+
data, msg = parse_response(response)
|
| 117 |
+
return data, msg
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def save_task(image_url, show_image, task_id, text_description, did, ip):
|
| 121 |
+
timestamp = str(int(time.time()))
|
| 122 |
+
signature = generate_signature(
|
| 123 |
+
key=secret_key,
|
| 124 |
+
did=did,
|
| 125 |
+
timestamp=timestamp,
|
| 126 |
+
)
|
| 127 |
+
headers = {
|
| 128 |
+
'Did': did,
|
| 129 |
+
'X-Timestamp': timestamp,
|
| 130 |
+
'X-Signature': signature,
|
| 131 |
+
'X-Forwarded-For': ip,
|
| 132 |
+
'X-AppId': app_id,
|
| 133 |
+
}
|
| 134 |
+
data = {
|
| 135 |
+
"agentVersion": agent_version,
|
| 136 |
+
"agentName": agent_name,
|
| 137 |
+
"image": image_url,
|
| 138 |
+
"showImage": show_image,
|
| 139 |
+
"taskId": task_id,
|
| 140 |
+
"textDescription": text_description,
|
| 141 |
+
}
|
| 142 |
+
response = requests.post(base_url + create_save_task_url, json=data, headers=headers)
|
| 143 |
+
data, msg = parse_response(response)
|
| 144 |
+
return data, msg
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def query_task(task_id, execution_id, did, ip):
|
| 148 |
+
timestamp = str(int(time.time()))
|
| 149 |
+
signature = generate_signature(
|
| 150 |
+
key=secret_key,
|
| 151 |
+
did=did,
|
| 152 |
+
timestamp=timestamp,
|
| 153 |
+
)
|
| 154 |
+
headers = {
|
| 155 |
+
'Did': did,
|
| 156 |
+
'X-Timestamp': timestamp,
|
| 157 |
+
'X-Signature': signature,
|
| 158 |
+
'X-Forwarded-For': ip,
|
| 159 |
+
'X-AppId': app_id,
|
| 160 |
+
}
|
| 161 |
+
data = {
|
| 162 |
+
"agentVersion": agent_version,
|
| 163 |
+
"agentName": agent_name,
|
| 164 |
+
"taskId": task_id,
|
| 165 |
+
"executionId": execution_id,
|
| 166 |
+
}
|
| 167 |
+
response = requests.post(base_url + query_task_url, json=data, headers=headers)
|
| 168 |
+
data, msg = parse_response(response)
|
| 169 |
+
return data, msg
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
def upload_image(image, did, ip):
|
| 173 |
+
if image is None:
|
| 174 |
+
return None
|
| 175 |
+
timestamp = str(int(time.time()))
|
| 176 |
+
signature = generate_signature(
|
| 177 |
+
key=secret_key,
|
| 178 |
+
did=did,
|
| 179 |
+
timestamp=timestamp,
|
| 180 |
+
)
|
| 181 |
+
upload_url = upload_image_url
|
| 182 |
+
image_format = image.format if image.format else "PNG"
|
| 183 |
+
mime_type = f"image/{image_format.lower()}"
|
| 184 |
+
with BytesIO() as m_img:
|
| 185 |
+
image.save(m_img, format=image_format)
|
| 186 |
+
m_img.seek(0)
|
| 187 |
+
files = {'image': (f"main_image.{image_format.lower()}", m_img, mime_type)}
|
| 188 |
+
headers = {
|
| 189 |
+
'Did': did,
|
| 190 |
+
'X-Timestamp': timestamp,
|
| 191 |
+
'X-Signature': signature,
|
| 192 |
+
'X-Forwarded-For': ip,
|
| 193 |
+
'X-AppId': app_id,
|
| 194 |
+
}
|
| 195 |
+
response = requests.post(base_url + upload_url, files=files, headers=headers)
|
| 196 |
+
data, msg = parse_response(response)
|
| 197 |
+
return data, msg
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def load_description(file_path):
|
| 201 |
+
with open(file_path, 'r', encoding='utf-8') as file:
|
| 202 |
+
content = file.read()
|
| 203 |
+
return content
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def generate_image(main_image, text_description, did, request: gr.Request):
|
| 207 |
+
if not did:
|
| 208 |
+
did = str(uuid.uuid4())
|
| 209 |
+
if main_image is None:
|
| 210 |
+
m = "Please upload both the main image and the background reference image before generating."
|
| 211 |
+
return gr.Warning(m), did
|
| 212 |
+
|
| 213 |
+
client_ip = request.client.host
|
| 214 |
+
x_forwarded_for = request.headers.get('x-forwarded-for')
|
| 215 |
+
if x_forwarded_for:
|
| 216 |
+
client_ip = x_forwarded_for
|
| 217 |
+
|
| 218 |
+
upload_image_data, upload_image_msg = upload_image(
|
| 219 |
+
image=main_image,
|
| 220 |
+
did=did,
|
| 221 |
+
ip=client_ip,
|
| 222 |
+
)
|
| 223 |
+
if not upload_image_data:
|
| 224 |
+
return gr.Warning(upload_image_msg), did
|
| 225 |
+
image_url = upload_image_data.get("image")
|
| 226 |
+
if not image_url:
|
| 227 |
+
m = 'Upload image failed.'
|
| 228 |
+
return gr.Warning(m), did
|
| 229 |
+
create_task_data, create_task_msg = create_task(
|
| 230 |
+
image_url=image_url,
|
| 231 |
+
did=did,
|
| 232 |
+
ip=client_ip,
|
| 233 |
+
)
|
| 234 |
+
if not create_task_data:
|
| 235 |
+
return gr.Warning(create_task_msg), did
|
| 236 |
+
task_id = create_task_data.get("taskId")
|
| 237 |
+
show_image = create_task_data.get("showImage")
|
| 238 |
+
if not task_id or not show_image:
|
| 239 |
+
m = 'Create task failed.'
|
| 240 |
+
return gr.Warning(m), did
|
| 241 |
+
save_task_data, save_task_msg = save_task(
|
| 242 |
+
image_url=image_url,
|
| 243 |
+
show_image=show_image,
|
| 244 |
+
task_id=task_id,
|
| 245 |
+
text_description=text_description,
|
| 246 |
+
did=did,
|
| 247 |
+
ip=client_ip,
|
| 248 |
+
)
|
| 249 |
+
if not save_task_data:
|
| 250 |
+
return gr.Warning(save_task_msg), did
|
| 251 |
+
save_task_id = save_task_data.get("taskId")
|
| 252 |
+
save_show_image = save_task_data.get("showImage")
|
| 253 |
+
if not save_task_id or not save_show_image:
|
| 254 |
+
return gr.Warning('Save task failed'), did
|
| 255 |
+
start_task_data, start_task_msg = start_task(
|
| 256 |
+
task_id=save_task_id,
|
| 257 |
+
did=did,
|
| 258 |
+
ip=client_ip,
|
| 259 |
+
)
|
| 260 |
+
if not start_task_data:
|
| 261 |
+
return gr.Warning(start_task_msg), did
|
| 262 |
+
execution_id = start_task_data.get("executionId")
|
| 263 |
+
if not execution_id:
|
| 264 |
+
m = "The task failed to start."
|
| 265 |
+
return gr.Warning(m), did
|
| 266 |
+
start_time = int(time.time())
|
| 267 |
+
while True:
|
| 268 |
+
m = "Query task failed."
|
| 269 |
+
query_task_data, query_task_msg = query_task(
|
| 270 |
+
task_id=save_task_id,
|
| 271 |
+
execution_id=execution_id,
|
| 272 |
+
did=did,
|
| 273 |
+
ip=client_ip,
|
| 274 |
+
)
|
| 275 |
+
print("Query task data:", query_task_data)
|
| 276 |
+
print("Query task msg:", query_task_msg)
|
| 277 |
+
print("Time:", int(time.time()) - start_time)
|
| 278 |
+
if not query_task_data:
|
| 279 |
+
return gr.Warning(query_task_msg), did
|
| 280 |
+
executions = query_task_data.get("executions")
|
| 281 |
+
if not executions:
|
| 282 |
+
return gr.Warning(m), did
|
| 283 |
+
results = executions[0].get("result")
|
| 284 |
+
if not results:
|
| 285 |
+
return gr.Warning(m), did
|
| 286 |
+
status = results[0].get("status")
|
| 287 |
+
if status == "Failed":
|
| 288 |
+
return gr.Warning(m), did
|
| 289 |
+
elif status == "Success" or status == "Blocked":
|
| 290 |
+
img = results[0].get("image")
|
| 291 |
+
if img and str(img).strip() != "":
|
| 292 |
+
return url_to_image(img, ip=client_ip), did
|
| 293 |
+
end_time = int(time.time())
|
| 294 |
+
if end_time - start_time > 3600:
|
| 295 |
+
m = 'Query task timeout.'
|
| 296 |
+
return gr.Warning(m), did
|
| 297 |
+
time.sleep(4)
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
def preprocess_image(main_image):
|
| 301 |
+
return main_image
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
css = """
|
| 305 |
+
.text-box {
|
| 306 |
+
min-height: 260px !important;
|
| 307 |
+
}
|
| 308 |
+
.image-container {
|
| 309 |
+
min-height: 260px !important;
|
| 310 |
+
}
|
| 311 |
+
.image-container img {
|
| 312 |
+
max-height: 500px;
|
| 313 |
+
width: auto;
|
| 314 |
+
}
|
| 315 |
+
.hide-buttons .source-selection {
|
| 316 |
+
display: none;
|
| 317 |
+
}
|
| 318 |
+
#example-images .gallery {
|
| 319 |
+
display: flex;
|
| 320 |
+
flex-wrap: wrap;
|
| 321 |
+
}
|
| 322 |
+
#example-images .gallery-item .container{
|
| 323 |
+
width: 100%;
|
| 324 |
+
max-width: 100%;
|
| 325 |
+
}
|
| 326 |
+
#example-images .gallery-item {
|
| 327 |
+
flex: 0 0 30%;
|
| 328 |
+
max-width: 30%;
|
| 329 |
+
box-sizing: border-box;
|
| 330 |
+
display: flex;
|
| 331 |
+
text-align: center;
|
| 332 |
+
justify-content: center;
|
| 333 |
+
|
| 334 |
+
}
|
| 335 |
+
@media (max-width: 767px) {
|
| 336 |
+
#example-res-images th {
|
| 337 |
+
font-size: 12px;
|
| 338 |
+
word-wrap: break-word;
|
| 339 |
+
word-break: break-word;
|
| 340 |
+
white-space: normal;
|
| 341 |
+
overflow-wrap: break-word;
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
"""
|
| 345 |
+
|
| 346 |
+
with gr.Blocks(css=css) as WeShop:
|
| 347 |
+
current_did = gr.State(value='')
|
| 348 |
+
gr.HTML(load_description("assets/title.html"))
|
| 349 |
+
with gr.Row():
|
| 350 |
+
with gr.Column():
|
| 351 |
+
gr.Markdown("#### Step 1: Upload a person image")
|
| 352 |
+
main_image_input = gr.Image(
|
| 353 |
+
type="pil",
|
| 354 |
+
label="Main Image",
|
| 355 |
+
elem_classes=["image-container", "hide-buttons"]
|
| 356 |
+
)
|
| 357 |
+
clothing_example = gr.Examples(
|
| 358 |
+
inputs=main_image_input,
|
| 359 |
+
examples_per_page=12,
|
| 360 |
+
examples=human_list_path,
|
| 361 |
+
elem_id="example-images",
|
| 362 |
+
outputs=main_image_input
|
| 363 |
+
)
|
| 364 |
+
|
| 365 |
+
with gr.Column():
|
| 366 |
+
gr.Markdown("#### Step 2: Input pose description")
|
| 367 |
+
text_description_input = gr.Textbox(
|
| 368 |
+
label="Text Description",
|
| 369 |
+
placeholder="Enter pose description here...",
|
| 370 |
+
lines=9,
|
| 371 |
+
elem_classes=["text-box"]
|
| 372 |
+
)
|
| 373 |
+
text_description_example = gr.Examples(
|
| 374 |
+
inputs=text_description_input,
|
| 375 |
+
examples_per_page=12,
|
| 376 |
+
examples=[
|
| 377 |
+
"Keep the background unchanged and only change the model's pose",
|
| 378 |
+
"Follow-shot view",
|
| 379 |
+
"Switch to a back view",
|
| 380 |
+
"Change pose",
|
| 381 |
+
"The scene stays the same, while the outfit is shown from multiple angles",
|
| 382 |
+
"Dynamic walking pose",
|
| 383 |
+
"Simulating a model walking motion",
|
| 384 |
+
"Low-angle upward shoot",
|
| 385 |
+
],
|
| 386 |
+
outputs=text_description_input
|
| 387 |
+
)
|
| 388 |
+
with gr.Column():
|
| 389 |
+
with gr.Row():
|
| 390 |
+
with gr.Column():
|
| 391 |
+
gr.Markdown("#### Step 3: Press 'Generate' to get the result")
|
| 392 |
+
output = gr.Image(
|
| 393 |
+
label="Result",
|
| 394 |
+
elem_classes=["image-container", "hide-buttons"],
|
| 395 |
+
interactive=False
|
| 396 |
+
)
|
| 397 |
+
with gr.Row():
|
| 398 |
+
submit_button = gr.Button("Generate")
|
| 399 |
+
submit_button.click(
|
| 400 |
+
fn=generate_image,
|
| 401 |
+
inputs=[main_image_input, text_description_input, current_did],
|
| 402 |
+
outputs=[output, current_did],
|
| 403 |
+
concurrency_limit=None
|
| 404 |
+
)
|
| 405 |
+
with gr.Column():
|
| 406 |
+
show_case = gr.Examples(
|
| 407 |
+
examples=[
|
| 408 |
+
[
|
| 409 |
+
"assets/human/07.png",
|
| 410 |
+
"Dynamic walking pose",
|
| 411 |
+
"assets/examples/result_07_01.jpeg",
|
| 412 |
+
],
|
| 413 |
+
[
|
| 414 |
+
"assets/human/01.png",
|
| 415 |
+
"Follow-shot view",
|
| 416 |
+
"assets/examples/result_01_01.jpeg"
|
| 417 |
+
],
|
| 418 |
+
[
|
| 419 |
+
"assets/human/06.png",
|
| 420 |
+
"Change pose",
|
| 421 |
+
"assets/examples/result_06_01.jpeg"
|
| 422 |
+
],
|
| 423 |
+
[
|
| 424 |
+
"assets/human/04.png",
|
| 425 |
+
"Keep the background unchanged and only change the model's pose",
|
| 426 |
+
"assets/examples/result_04_01.jpeg"
|
| 427 |
+
],
|
| 428 |
+
],
|
| 429 |
+
inputs=[main_image_input, text_description_input, output],
|
| 430 |
+
elem_id="example-res-images"
|
| 431 |
+
)
|
| 432 |
+
main_image_input.upload(
|
| 433 |
+
fn=preprocess_image,
|
| 434 |
+
inputs=[main_image_input],
|
| 435 |
+
outputs=main_image_input
|
| 436 |
+
)
|
| 437 |
+
WeShop.queue(api_open=False).launch(show_api=False)
|
assets/examples/result_01_01.jpeg
ADDED
|
Git LFS Details
|
assets/examples/result_04_01.jpeg
ADDED
|
Git LFS Details
|
assets/examples/result_06_01.jpeg
ADDED
|
Git LFS Details
|
assets/examples/result_07_01.jpeg
ADDED
|
Git LFS Details
|
assets/human/01.png
ADDED
|
Git LFS Details
|
assets/human/02.png
ADDED
|
Git LFS Details
|
assets/human/03.png
ADDED
|
Git LFS Details
|
assets/human/04.png
ADDED
|
Git LFS Details
|
assets/human/05.jpeg
ADDED
|
Git LFS Details
|
assets/human/06.png
ADDED
|
Git LFS Details
|
assets/human/07.png
ADDED
|
Git LFS Details
|
assets/human/08.png
ADDED
|
Git LFS Details
|
assets/human/09.png
ADDED
|
Git LFS Details
|
assets/title.html
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<title>WeShopAI Pose Generator</title>
|
| 6 |
+
<style>
|
| 7 |
+
.title-text {
|
| 8 |
+
display: flex;
|
| 9 |
+
justify-content: center;
|
| 10 |
+
align-items: center;
|
| 11 |
+
text-align: center;
|
| 12 |
+
font-size: 40px;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
.center-content {
|
| 16 |
+
display: flex;
|
| 17 |
+
justify-content: center;
|
| 18 |
+
align-items: center;
|
| 19 |
+
text-align: center;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.content-text {
|
| 23 |
+
text-align: center;
|
| 24 |
+
font-size: 14px;
|
| 25 |
+
padding-right: 10%;
|
| 26 |
+
padding-left: 10%;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
@media (max-width: 767px) {
|
| 30 |
+
.title-text {
|
| 31 |
+
font-size: 30px;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.content-text {
|
| 35 |
+
font-size: 12px;
|
| 36 |
+
padding-right: 2%;
|
| 37 |
+
padding-left: 2%;
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
@media (max-width: 450px) {
|
| 42 |
+
.title-text {
|
| 43 |
+
font-size: 24px;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.content-text {
|
| 47 |
+
font-size: 12px;
|
| 48 |
+
padding-right: 0;
|
| 49 |
+
padding-left: 0;
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
@media (max-width: 360px) {
|
| 54 |
+
.title-text {
|
| 55 |
+
font-size: 22px;
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
</style>
|
| 59 |
+
</head>
|
| 60 |
+
<body>
|
| 61 |
+
<div>
|
| 62 |
+
<div>
|
| 63 |
+
<div class="title-text">
|
| 64 |
+
<b>WeShopAI Pose Generator</b>
|
| 65 |
+
</div>
|
| 66 |
+
<br />
|
| 67 |
+
<div class="center-content">
|
| 68 |
+
<a href="https://www.weshop.com/"
|
| 69 |
+
><img
|
| 70 |
+
src="https://img.shields.io/static/v1?label=Official Website&message=CN&color=red"
|
| 71 |
+
/></a>
|
| 72 |
+
 
|
| 73 |
+
<a href="https://www.weshop.ai/"
|
| 74 |
+
><img
|
| 75 |
+
src="https://img.shields.io/static/v1?label=Official Website&message=EN&color=blue"
|
| 76 |
+
/></a>
|
| 77 |
+
</div>
|
| 78 |
+
<br />
|
| 79 |
+
<div class="content-text">
|
| 80 |
+
Commercial clients are encouraged to evaluate the API capabilities
|
| 81 |
+
offered at weshop.ai.
|
| 82 |
+
<a
|
| 83 |
+
href="https://open.weshop.ai/authorization/apikey"
|
| 84 |
+
style="font-weight: bold"
|
| 85 |
+
target="_blank"
|
| 86 |
+
>Get an API Key</a
|
| 87 |
+
>
|
| 88 |
+
to explore further.
|
| 89 |
+
</div>
|
| 90 |
+
<br />
|
| 91 |
+
<div class="content-text">
|
| 92 |
+
<strong>Disclaimer: </strong>The WeShopAI-Pose-Generator Demo on
|
| 93 |
+
HuggingFace space is free for trials. Any solicitation for payment
|
| 94 |
+
based on the free features we provide on HuggingFace Space is a
|
| 95 |
+
fraudulent act. Beware of scams and do not fall victim to deceit.
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
</div>
|
| 99 |
+
</body>
|
| 100 |
+
</html>
|