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 |
|
@@ -236,7 +308,7 @@ exp_config = {
|
|
236 |
- **Demo:** [video](https://huggingface.co/OpenDILabCommunity/HalfCheetah-v3-DDPG/blob/main/replay.mp4)
|
237 |
<!-- Provide the size information for the model. -->
|
238 |
- **Parameters total size:** 1126.05 KB
|
239 |
-
- **Last Update Date:** 2023-09-
|
240 |
|
241 |
## Environments
|
242 |
<!-- 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 DDPGAgent
|
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 = DDPGAgent(env_id="HalfCheetah-v3", exp_name="HalfCheetah-v3-DDPG", 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 DDPGAgent
|
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-DDPG")
|
107 |
+
# Instantiate the agent
|
108 |
+
agent = DDPGAgent(env_id="HalfCheetah-v3", exp_name="HalfCheetah-v3-DDPG", 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 DDPGAgent
|
131 |
+
from huggingface_ding import push_model_to_hub
|
132 |
+
|
133 |
+
# Instantiate the agent
|
134 |
+
agent = DDPGAgent(env_id="HalfCheetah-v3", exp_name="HalfCheetah-v3-DDPG")
|
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="DDPG",
|
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/ddpg.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="./ddpg/halfcheetah_ddpg_deploy.py",
|
172 |
+
usage_file_by_huggingface_ding="./ddpg/halfcheetah_ddpg_download.py",
|
173 |
+
train_file="./ddpg/halfcheetah_ddpg.py",
|
174 |
+
repo_id="OpenDILabCommunity/HalfCheetah-v3-DDPG",
|
175 |
+
create_repo=False
|
176 |
+
)
|
177 |
+
|
178 |
```
|
179 |
</details>
|
180 |
|
|
|
308 |
- **Demo:** [video](https://huggingface.co/OpenDILabCommunity/HalfCheetah-v3-DDPG/blob/main/replay.mp4)
|
309 |
<!-- Provide the size information for the model. -->
|
310 |
- **Parameters total size:** 1126.05 KB
|
311 |
+
- **Last Update Date:** 2023-09-20
|
312 |
|
313 |
## Environments
|
314 |
<!-- 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. -->
|