from html import escape
from urllib.parse import quote
import gradio as gr
from config import (
BASE_DIR,
CATEGORIES,
CITATION_BIBTEX,
DEFAULT_MOTION,
HIGHLIGHT_VIDEOS,
MODELS,
MODEL_KEYS,
RESOURCE_LINKS,
get_motion_metadata,
get_motions_by_category,
get_video_path,
label_to_key,
)
gr.set_static_paths(paths=[str(BASE_DIR / "videos"), str(BASE_DIR / "assets")])
FILE_ROUTE_PREFIX = "/gradio_api/file=" if int(gr.__version__.split(".", 1)[0]) >= 6 else "/file="
with open(BASE_DIR / "style.css", encoding="utf-8") as css_file:
CUSTOM_CSS = css_file.read()
def static_src(*relative_parts: str) -> str:
return file_src(BASE_DIR.joinpath(*relative_parts))
def file_src(path) -> str:
return f"{FILE_ROUTE_PREFIX}{quote(str(path), safe='/')}"
def render_resource_links() -> str:
cards = []
for item in RESOURCE_LINKS:
cards.append(
f"""
{escape(item["label"])}{escape(item["note"])}
"""
)
return "".join(cards)
def build_hero_html() -> str:
return f"""
MuscleMimic Research Space
Checkpoint comparison and policy rollouts
MuscleMimic lets us train and evaluate many checkpoints and training recipes at scale.
Here we showcase a few interesting ones: side-by-side checkpoint comparisons and
policy rollouts across locomotion, manipulation, and dynamic motions.
Compare MyoFullBody checkpoints on KIT locomotion motions.
The colored character is the reference motion and the other character is the rollout.
"""
def build_highlights_html() -> str:
cards = []
for item in HIGHLIGHT_VIDEOS:
cards.append(
f"""
{escape(item["tag"])}
{escape(item["label"])}
"""
)
return f"""
Policy Rollouts
Policy rollouts across locomotion, manipulation, and dynamic motions
Selected examples spanning locomotion, object interaction, and more dynamic motions.
In each video, the blue or purple character is the reference motion.