Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -70,7 +70,21 @@ python3 -u run.py
|
|
| 70 |
```
|
| 71 |
**run.py**
|
| 72 |
```python
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
```
|
| 75 |
</details>
|
| 76 |
|
|
@@ -85,7 +99,18 @@ python3 -u run.py
|
|
| 85 |
```
|
| 86 |
**run.py**
|
| 87 |
```python
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
```
|
| 90 |
</details>
|
| 91 |
|
|
@@ -102,7 +127,54 @@ python3 -u train.py
|
|
| 102 |
```
|
| 103 |
**train.py**
|
| 104 |
```python
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
```
|
| 107 |
</details>
|
| 108 |
|
|
@@ -235,7 +307,7 @@ exp_config = {
|
|
| 235 |
- **Demo:** [video](https://huggingface.co/OpenDILabCommunity/HalfCheetah-v3-TD3/blob/main/replay.mp4)
|
| 236 |
<!-- Provide the size information for the model. -->
|
| 237 |
- **Parameters total size:** 1690.06 KB
|
| 238 |
-
- **Last Update Date:** 2023-09-
|
| 239 |
|
| 240 |
## Environments
|
| 241 |
<!-- Address questions around what environment the model is intended to be trained and deployed at, including the necessary information needed to be provided for future users. -->
|
|
|
|
| 70 |
```
|
| 71 |
**run.py**
|
| 72 |
```python
|
| 73 |
+
from ding.bonus import SACAgent
|
| 74 |
+
from ding.config import Config
|
| 75 |
+
from easydict import EasyDict
|
| 76 |
+
import torch
|
| 77 |
+
|
| 78 |
+
# Pull model from files which are git cloned from huggingface
|
| 79 |
+
policy_state_dict = torch.load("pytorch_model.bin", map_location=torch.device("cpu"))
|
| 80 |
+
cfg = EasyDict(Config.file_to_dict("policy_config.py").cfg_dict)
|
| 81 |
+
# Instantiate the agent
|
| 82 |
+
agent = SACAgent(env_id="HalfCheetah-v3", exp_name="HalfCheetah-v3-TD3", cfg=cfg.exp_config, policy_state_dict=policy_state_dict)
|
| 83 |
+
# Continue training
|
| 84 |
+
agent.train(step=5000)
|
| 85 |
+
# Render the new agent performance
|
| 86 |
+
agent.deploy(enable_save_replay=True)
|
| 87 |
+
|
| 88 |
```
|
| 89 |
</details>
|
| 90 |
|
|
|
|
| 99 |
```
|
| 100 |
**run.py**
|
| 101 |
```python
|
| 102 |
+
from ding.bonus import TD3Agent
|
| 103 |
+
from huggingface_ding import pull_model_from_hub
|
| 104 |
+
|
| 105 |
+
# Pull model from Hugggingface hub
|
| 106 |
+
policy_state_dict, cfg = pull_model_from_hub(repo_id="OpenDILabCommunity/HalfCheetah-v3-TD3")
|
| 107 |
+
# Instantiate the agent
|
| 108 |
+
agent = TD3Agent(env_id="HalfCheetah-v3", exp_name="HalfCheetah-v3-TD3", cfg=cfg.exp_config, policy_state_dict=policy_state_dict)
|
| 109 |
+
# Continue training
|
| 110 |
+
agent.train(step=5000)
|
| 111 |
+
# Render the new agent performance
|
| 112 |
+
agent.deploy(enable_save_replay=True)
|
| 113 |
+
|
| 114 |
```
|
| 115 |
</details>
|
| 116 |
|
|
|
|
| 127 |
```
|
| 128 |
**train.py**
|
| 129 |
```python
|
| 130 |
+
from ding.bonus import TD3Agent
|
| 131 |
+
from huggingface_ding import push_model_to_hub
|
| 132 |
+
|
| 133 |
+
# Instantiate the agent
|
| 134 |
+
agent = TD3Agent(env_id="HalfCheetah-v3", exp_name="HalfCheetah-v3-TD3")
|
| 135 |
+
# Train the agent
|
| 136 |
+
return_ = agent.train(step=int(5000000))
|
| 137 |
+
# Push model to huggingface hub
|
| 138 |
+
push_model_to_hub(
|
| 139 |
+
agent=agent.best,
|
| 140 |
+
env_name="OpenAI/Gym/MuJoCo",
|
| 141 |
+
task_name="HalfCheetah-v3",
|
| 142 |
+
algo_name="TD3",
|
| 143 |
+
wandb_url=return_.wandb_url,
|
| 144 |
+
github_repo_url="https://github.com/opendilab/DI-engine",
|
| 145 |
+
github_doc_model_url="https://di-engine-docs.readthedocs.io/en/latest/12_policies/td3.html",
|
| 146 |
+
github_doc_env_url="https://di-engine-docs.readthedocs.io/en/latest/13_envs/mujoco.html",
|
| 147 |
+
installation_guide='''
|
| 148 |
+
sudo apt update -y \
|
| 149 |
+
&& sudo apt install -y \
|
| 150 |
+
build-essential \
|
| 151 |
+
libgl1-mesa-dev \
|
| 152 |
+
libgl1-mesa-glx \
|
| 153 |
+
libglew-dev \
|
| 154 |
+
libosmesa6-dev \
|
| 155 |
+
libglfw3 \
|
| 156 |
+
libglfw3-dev \
|
| 157 |
+
libsdl2-dev \
|
| 158 |
+
libsdl2-image-dev \
|
| 159 |
+
libglm-dev \
|
| 160 |
+
libfreetype6-dev \
|
| 161 |
+
patchelf
|
| 162 |
+
|
| 163 |
+
mkdir -p ~/.mujoco
|
| 164 |
+
wget https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz -O mujoco.tar.gz
|
| 165 |
+
tar -xf mujoco.tar.gz -C ~/.mujoco
|
| 166 |
+
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.mujoco/mjpro210/bin:~/.mujoco/mujoco210/bin" >> ~/.bashrc
|
| 167 |
+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.mujoco/mjpro210/bin:~/.mujoco/mujoco210/bin
|
| 168 |
+
pip3 install "cython<3"
|
| 169 |
+
pip3 install DI-engine[common_env]
|
| 170 |
+
''',
|
| 171 |
+
usage_file_by_git_clone="./td3/halfcheetah_td3_deploy.py",
|
| 172 |
+
usage_file_by_huggingface_ding="./td3/halfcheetah_td3_download.py",
|
| 173 |
+
train_file="./td3/halfcheetah_td3.py",
|
| 174 |
+
repo_id="OpenDILabCommunity/HalfCheetah-v3-TD3",
|
| 175 |
+
create_repo=False
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
```
|
| 179 |
</details>
|
| 180 |
|
|
|
|
| 307 |
- **Demo:** [video](https://huggingface.co/OpenDILabCommunity/HalfCheetah-v3-TD3/blob/main/replay.mp4)
|
| 308 |
<!-- Provide the size information for the model. -->
|
| 309 |
- **Parameters total size:** 1690.06 KB
|
| 310 |
+
- **Last Update Date:** 2023-09-20
|
| 311 |
|
| 312 |
## Environments
|
| 313 |
<!-- Address questions around what environment the model is intended to be trained and deployed at, including the necessary information needed to be provided for future users. -->
|