Spaces:
Build error
Build error
Download src/huggingface/get_best_mp4.py from c-gohlke/LitRL-Inference: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/c-gohlke/LitRL-Inference/resolve/main/src/huggingface/get_best_mp4.py
- Command line
-
hf download hf://spaces/c-gohlke/LitRL-Inference/src/huggingface/get_best_mp4.py
-
curl -L -o get_best_mp4.py https://huggingface.co/spaces/c-gohlke/LitRL-Inference/resolve/main/src/huggingface/get_best_mp4.py
1.18 kB
| from pathlib import Path | |
| def get_mp4_paths(environments: list[str]) -> dict[str, Path]: | |
| mp4_paths: dict[str, Path] = {} | |
| for env in environments: | |
| mp4_paths[env] = get_best_mp4(env) | |
| return mp4_paths | |
| def get_best_mp4(env: str) -> Path: | |
| hf_env_results_path = f"models/{env}/results.yaml" | |
| local_env_results_path = hf_hub_download(repo_id=MODEL_REPO, repo_type=MODEL_REPO_TYPE, filename=hf_env_results_path) | |
| with open(local_env_results_path, "r") as f: | |
| env_results = yaml.load(f, Loader=yaml.FullLoader) | |
| best_model_type = max(env_results, key=lambda model: env_results[model]) | |
| model_results_path = f"models/{env}/{best_model_type}/results.yaml" | |
| local_model_results_path = hf_hub_download(repo_id=MODEL_REPO, repo_type=MODEL_REPO_TYPE, filename=model_results_path) | |
| with open(local_model_results_path, "r") as f: | |
| model_results = yaml.load(f, Loader=yaml.FullLoader) | |
| best_model = max(model_results, key=lambda model: model_results[model]) | |
| hf_gif_path = f"models/{env}/{best_model_type}/{best_model}/demo.mp4" | |
| return Path(hf_hub_download(repo_id=MODEL_REPO, repo_type=MODEL_REPO_TYPE, filename=hf_gif_path)) |