Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,6 +55,9 @@ PARAM_DIMS = [10, 63, 45, 45, 3, 10, 3, 3]
|
|
| 55 |
PARAM_NAMES = ["betas", "body_pose", "left_hand_pose", "right_hand_pose",
|
| 56 |
"trans", "expression", "jaw_pose", "eye_pose"]
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
# =====================================================================
|
| 59 |
# Install/Import Dependencies
|
| 60 |
# =====================================================================
|
|
@@ -497,7 +500,7 @@ def create_animation_html(verts: np.ndarray, faces: np.ndarray, fps: int = 20,
|
|
| 497 |
mesh = go.Mesh3d(
|
| 498 |
x=verts[0, :, 0], y=verts[0, :, 1], z=verts[0, :, 2],
|
| 499 |
i=i, j=j, k=k, flatshading=True, opacity=0.6,
|
| 500 |
-
color=
|
| 501 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2)
|
| 502 |
)
|
| 503 |
|
|
@@ -506,7 +509,7 @@ def create_animation_html(verts: np.ndarray, faces: np.ndarray, fps: int = 20,
|
|
| 506 |
data=[go.Mesh3d(
|
| 507 |
x=verts[t, :, 0], y=verts[t, :, 1], z=verts[t, :, 2],
|
| 508 |
i=i, j=j, k=k, flatshading=True, opacity=0.6,
|
| 509 |
-
color=
|
| 510 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2)
|
| 511 |
)],
|
| 512 |
name=str(t)
|
|
@@ -613,12 +616,12 @@ def create_side_by_side_html(verts1, faces1, verts2, faces2, title1="", title2="
|
|
| 613 |
|
| 614 |
mesh1 = go.Mesh3d(
|
| 615 |
x=verts1[0, :, 0], y=verts1[0, :, 1], z=verts1[0, :, 2],
|
| 616 |
-
i=i1, j=j1, k=k1, flatshading=True, opacity=0.6, color=
|
| 617 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2), scene='scene'
|
| 618 |
)
|
| 619 |
mesh2 = go.Mesh3d(
|
| 620 |
x=verts2[0, :, 0], y=verts2[0, :, 1], z=verts2[0, :, 2],
|
| 621 |
-
i=i2, j=j2, k=k2, flatshading=True, opacity=0.6, color=
|
| 622 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2), scene='scene2'
|
| 623 |
)
|
| 624 |
|
|
@@ -631,10 +634,10 @@ def create_side_by_side_html(verts1, faces1, verts2, faces2, title1="", title2="
|
|
| 631 |
name=str(t),
|
| 632 |
data=[
|
| 633 |
go.Mesh3d(x=verts1[t, :, 0], y=verts1[t, :, 1], z=verts1[t, :, 2],
|
| 634 |
-
i=i1, j=j1, k=k1, flatshading=True, opacity=0.6, color=
|
| 635 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2), scene='scene'),
|
| 636 |
go.Mesh3d(x=verts2[t, :, 0], y=verts2[t, :, 1], z=verts2[t, :, 2],
|
| 637 |
-
i=i2, j=j2, k=k2, flatshading=True, opacity=0.6, color=
|
| 638 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2), scene='scene2')
|
| 639 |
]
|
| 640 |
))
|
|
@@ -811,6 +814,20 @@ def create_gradio_interface():
|
|
| 811 |
custom_css = """
|
| 812 |
.gradio-container { max-width: 1400px !important; }
|
| 813 |
.example-row { margin-top: 15px; padding: 12px; background: #f8f9fa; border-radius: 6px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 814 |
"""
|
| 815 |
|
| 816 |
example_list = list(_example_cache.values()) if _example_cache else []
|
|
@@ -857,10 +874,10 @@ def create_gradio_interface():
|
|
| 857 |
for item in example_list:
|
| 858 |
word, pid = item['word'], item['pid']
|
| 859 |
with gr.Row(elem_classes="example-row"):
|
| 860 |
-
with gr.Column(scale=1, min_width=
|
| 861 |
-
gr.
|
| 862 |
-
gr.
|
| 863 |
-
example_btn = gr.Button(
|
| 864 |
|
| 865 |
with gr.Column(scale=3, min_width=500):
|
| 866 |
example_html = gr.HTML(
|
|
|
|
| 55 |
PARAM_NAMES = ["betas", "body_pose", "left_hand_pose", "right_hand_pose",
|
| 56 |
"trans", "expression", "jaw_pose", "eye_pose"]
|
| 57 |
|
| 58 |
+
# Visualization defaults
|
| 59 |
+
AVATAR_COLOR = "#5CB85C"
|
| 60 |
+
|
| 61 |
# =====================================================================
|
| 62 |
# Install/Import Dependencies
|
| 63 |
# =====================================================================
|
|
|
|
| 500 |
mesh = go.Mesh3d(
|
| 501 |
x=verts[0, :, 0], y=verts[0, :, 1], z=verts[0, :, 2],
|
| 502 |
i=i, j=j, k=k, flatshading=True, opacity=0.6,
|
| 503 |
+
color=AVATAR_COLOR,
|
| 504 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2)
|
| 505 |
)
|
| 506 |
|
|
|
|
| 509 |
data=[go.Mesh3d(
|
| 510 |
x=verts[t, :, 0], y=verts[t, :, 1], z=verts[t, :, 2],
|
| 511 |
i=i, j=j, k=k, flatshading=True, opacity=0.6,
|
| 512 |
+
color=AVATAR_COLOR,
|
| 513 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2)
|
| 514 |
)],
|
| 515 |
name=str(t)
|
|
|
|
| 616 |
|
| 617 |
mesh1 = go.Mesh3d(
|
| 618 |
x=verts1[0, :, 0], y=verts1[0, :, 1], z=verts1[0, :, 2],
|
| 619 |
+
i=i1, j=j1, k=k1, flatshading=True, opacity=0.6, color=AVATAR_COLOR,
|
| 620 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2), scene='scene'
|
| 621 |
)
|
| 622 |
mesh2 = go.Mesh3d(
|
| 623 |
x=verts2[0, :, 0], y=verts2[0, :, 1], z=verts2[0, :, 2],
|
| 624 |
+
i=i2, j=j2, k=k2, flatshading=True, opacity=0.6, color=AVATAR_COLOR,
|
| 625 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2), scene='scene2'
|
| 626 |
)
|
| 627 |
|
|
|
|
| 634 |
name=str(t),
|
| 635 |
data=[
|
| 636 |
go.Mesh3d(x=verts1[t, :, 0], y=verts1[t, :, 1], z=verts1[t, :, 2],
|
| 637 |
+
i=i1, j=j1, k=k1, flatshading=True, opacity=0.6, color=AVATAR_COLOR,
|
| 638 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2), scene='scene'),
|
| 639 |
go.Mesh3d(x=verts2[t, :, 0], y=verts2[t, :, 1], z=verts2[t, :, 2],
|
| 640 |
+
i=i2, j=j2, k=k2, flatshading=True, opacity=0.6, color=AVATAR_COLOR,
|
| 641 |
lighting=dict(ambient=0.6, diffuse=0.7, specular=0.2), scene='scene2')
|
| 642 |
]
|
| 643 |
))
|
|
|
|
| 814 |
custom_css = """
|
| 815 |
.gradio-container { max-width: 1400px !important; }
|
| 816 |
.example-row { margin-top: 15px; padding: 12px; background: #f8f9fa; border-radius: 6px; }
|
| 817 |
+
.example-word-label {
|
| 818 |
+
text-align: center;
|
| 819 |
+
font-size: 28px !important;
|
| 820 |
+
font-weight: bold !important;
|
| 821 |
+
color: #2c3e50 !important;
|
| 822 |
+
margin: 10px 0 !important;
|
| 823 |
+
padding: 10px !important;
|
| 824 |
+
}
|
| 825 |
+
.example-variant-label {
|
| 826 |
+
text-align: center;
|
| 827 |
+
font-size: 14px !important;
|
| 828 |
+
color: #7f8c8d !important;
|
| 829 |
+
margin-bottom: 10px !important;
|
| 830 |
+
}
|
| 831 |
"""
|
| 832 |
|
| 833 |
example_list = list(_example_cache.values()) if _example_cache else []
|
|
|
|
| 874 |
for item in example_list:
|
| 875 |
word, pid = item['word'], item['pid']
|
| 876 |
with gr.Row(elem_classes="example-row"):
|
| 877 |
+
with gr.Column(scale=1, min_width=180):
|
| 878 |
+
gr.HTML(f'<div class="example-word-label">{word.upper()}</div>')
|
| 879 |
+
gr.HTML(f'<div class="example-variant-label">Variant: {pid}</div>')
|
| 880 |
+
example_btn = gr.Button("Load Example", size="sm", variant="secondary")
|
| 881 |
|
| 882 |
with gr.Column(scale=3, min_width=500):
|
| 883 |
example_html = gr.HTML(
|