Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,42 +1,77 @@
|
|
| 1 |
-
import textwrap
|
| 2 |
-
import subprocess
|
| 3 |
-
import shutil
|
| 4 |
import os
|
|
|
|
|
|
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
-
import torch
|
| 8 |
import gradio as gr
|
|
|
|
| 9 |
from huggingface_hub import hf_hub_download
|
| 10 |
|
| 11 |
-
|
| 12 |
REPO_ID = "kbrodt/sketch2pose"
|
| 13 |
API_TOKEN = os.environ["sketch2pose"]
|
| 14 |
ASSET_DIR = Path("./assets")
|
| 15 |
-
|
| 16 |
-
filename = "models_smplx_v1_1.zip"
|
| 17 |
-
smpl_path = hf_hub_download(
|
| 18 |
-
repo_id=REPO_ID,
|
| 19 |
-
repo_type="model",
|
| 20 |
-
filename=filename,
|
| 21 |
-
use_auth_token=API_TOKEN,
|
| 22 |
-
cache_dir=ASSET_DIR,
|
| 23 |
-
)
|
| 24 |
-
if not (ASSET_DIR / filename).is_file():
|
| 25 |
-
shutil.copy(smpl_path, ASSET_DIR)
|
| 26 |
-
|
| 27 |
-
subprocess.run("bash ./scripts/download.sh".split())
|
| 28 |
-
subprocess.run("bash ./scripts/prepare.sh".split())
|
| 29 |
-
|
| 30 |
-
|
| 31 |
SAVE_DIR = "output"
|
| 32 |
CMD = textwrap.dedent("""
|
| 33 |
python src/pose.py
|
| 34 |
--save-path {}
|
| 35 |
--img-path {}
|
| 36 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
def main():
|
|
|
|
|
|
|
| 40 |
save_dir = Path(SAVE_DIR)
|
| 41 |
save_dir.mkdir(parents=True, exist_ok=True)
|
| 42 |
|
|
@@ -77,7 +112,9 @@ def main():
|
|
| 77 |
gr.Checkbox(value=True, label="Pose naturalness"),
|
| 78 |
],
|
| 79 |
outputs=gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="SMPL 3D pose"),
|
| 80 |
-
examples=examples,
|
|
|
|
|
|
|
| 81 |
)
|
| 82 |
|
| 83 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import shutil
|
| 3 |
+
import subprocess
|
| 4 |
+
import textwrap
|
| 5 |
from pathlib import Path
|
| 6 |
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
+
import torch
|
| 9 |
from huggingface_hub import hf_hub_download
|
| 10 |
|
|
|
|
| 11 |
REPO_ID = "kbrodt/sketch2pose"
|
| 12 |
API_TOKEN = os.environ["sketch2pose"]
|
| 13 |
ASSET_DIR = Path("./assets")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
SAVE_DIR = "output"
|
| 15 |
CMD = textwrap.dedent("""
|
| 16 |
python src/pose.py
|
| 17 |
--save-path {}
|
| 18 |
--img-path {}
|
| 19 |
""")
|
| 20 |
+
TITLE = "Sketch2Pose: Estimating a 3D Character Pose from a Bitmap Sketch"
|
| 21 |
+
DESCRIPTION = '''
|
| 22 |
+
<table>
|
| 23 |
+
<th>
|
| 24 |
+
<ul>
|
| 25 |
+
<li><strong>Project</strong> <a href="http://www-labs.iro.umontreal.ca/~bmpix/sketch2pose/">sketch2pose</a></li>
|
| 26 |
+
<li><strong>Code</strong> <a href="https://github.com/kbrodt/sketch2pose">kbrodt/sketch2pose</a>
|
| 27 |
+
<li><strong>Paper</strong> <a href="https://dl.acm.org/doi/10.1145/3528223.3530106">ACM</a>
|
| 28 |
+
</ul>
|
| 29 |
+
<iframe src="https://ghbtns.com/github-btn.html?user=kbrodt&repo=sketch2pose&type=star&count=true&v=2&size=small" frameborder="0" scrolling="0" width="100" height="20"></iframe>
|
| 30 |
+
</th>
|
| 31 |
+
<th>
|
| 32 |
+
<video controls autoplay muted loop>
|
| 33 |
+
<source src="http://www-labs.iro.umontreal.ca/~bmpix/sketch2pose/sketch2pose.webm" type="video/mp4">
|
| 34 |
+
</video>
|
| 35 |
+
</th>
|
| 36 |
+
</table>
|
| 37 |
+
|
| 38 |
+
<details>
|
| 39 |
+
<summary>Citation</summary>
|
| 40 |
+
```
|
| 41 |
+
@article{brodt2022sketch2pose,
|
| 42 |
+
author = {Kirill Brodt and Mikhail Bessmeltsev},
|
| 43 |
+
title = {Sketch2Pose: Estimating a 3D Character Pose from a Bitmap Sketch},
|
| 44 |
+
journal = {ACM Transactions on Graphics},
|
| 45 |
+
year = {2022},
|
| 46 |
+
month = {7},
|
| 47 |
+
volume = {41},
|
| 48 |
+
number = {4},
|
| 49 |
+
doi = {10.1145/3528223.3530106},
|
| 50 |
+
}
|
| 51 |
+
```
|
| 52 |
+
</details>
|
| 53 |
+
'''
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def prepare():
|
| 57 |
+
filename = "models_smplx_v1_1.zip"
|
| 58 |
+
smpl_path = hf_hub_download(
|
| 59 |
+
repo_id=REPO_ID,
|
| 60 |
+
repo_type="model",
|
| 61 |
+
filename=filename,
|
| 62 |
+
use_auth_token=API_TOKEN,
|
| 63 |
+
cache_dir=ASSET_DIR,
|
| 64 |
+
)
|
| 65 |
+
if not (ASSET_DIR / filename).is_file():
|
| 66 |
+
shutil.copy(smpl_path, ASSET_DIR)
|
| 67 |
+
|
| 68 |
+
subprocess.run("bash ./scripts/download.sh".split())
|
| 69 |
+
subprocess.run("bash ./scripts/prepare.sh".split())
|
| 70 |
|
| 71 |
|
| 72 |
def main():
|
| 73 |
+
prepare()
|
| 74 |
+
|
| 75 |
save_dir = Path(SAVE_DIR)
|
| 76 |
save_dir.mkdir(parents=True, exist_ok=True)
|
| 77 |
|
|
|
|
| 112 |
gr.Checkbox(value=True, label="Pose naturalness"),
|
| 113 |
],
|
| 114 |
outputs=gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="SMPL 3D pose"),
|
| 115 |
+
examples=examples,
|
| 116 |
+
title=TITLE,
|
| 117 |
+
description=DESCRIPTION,
|
| 118 |
)
|
| 119 |
|
| 120 |
demo.launch()
|