Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -60,7 +60,23 @@ python3 -u run.py
|
|
60 |
```
|
61 |
**run.py**
|
62 |
```python
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
```
|
65 |
</details>
|
66 |
|
@@ -75,7 +91,20 @@ python3 -u run.py
|
|
75 |
```
|
76 |
**run.py**
|
77 |
```python
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
```
|
80 |
</details>
|
81 |
|
@@ -92,7 +121,31 @@ python3 -u train.py
|
|
92 |
```
|
93 |
**train.py**
|
94 |
```python
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
```
|
97 |
</details>
|
98 |
|
@@ -114,7 +167,7 @@ exp_config = {
|
|
114 |
'retry_waiting_time': 0.1,
|
115 |
'cfg_type': 'BaseEnvManagerDict'
|
116 |
},
|
117 |
-
'stop_value':
|
118 |
'n_evaluator_episode': 8,
|
119 |
'collector_env_num': 8,
|
120 |
'evaluator_env_num': 8,
|
@@ -166,8 +219,9 @@ exp_config = {
|
|
166 |
'mode': 'train_iter'
|
167 |
},
|
168 |
'figure_path': None,
|
|
|
169 |
'cfg_type': 'InteractionSerialEvaluatorDict',
|
170 |
-
'stop_value':
|
171 |
'n_episode': 8
|
172 |
}
|
173 |
},
|
@@ -210,7 +264,7 @@ exp_config = {
|
|
210 |
|
211 |
**Training Procedure**
|
212 |
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
213 |
-
- **Weights & Biases (wandb):** [monitor link](https://wandb.ai/
|
214 |
|
215 |
## Model Information
|
216 |
<!-- Provide the basic links for the model. -->
|
@@ -220,7 +274,7 @@ exp_config = {
|
|
220 |
- **Demo:** [video](https://huggingface.co/OpenDILabCommunity/PongNoFrameskip-v4-C51/blob/main/replay.mp4)
|
221 |
<!-- Provide the size information for the model. -->
|
222 |
- **Parameters total size:** 55276.2 KB
|
223 |
-
- **Last Update Date:** 2023-
|
224 |
|
225 |
## Environments
|
226 |
<!-- 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. -->
|
|
|
60 |
```
|
61 |
**run.py**
|
62 |
```python
|
63 |
+
from ding.bonus import C51Agent
|
64 |
+
from ding.config import Config
|
65 |
+
from easydict import EasyDict
|
66 |
+
import torch
|
67 |
+
|
68 |
+
# Pull model from files which are git cloned from huggingface
|
69 |
+
policy_state_dict = torch.load("pytorch_model.bin", map_location=torch.device("cpu"))
|
70 |
+
cfg = EasyDict(Config.file_to_dict("policy_config.py").cfg_dict)
|
71 |
+
# Instantiate the agent
|
72 |
+
agent = C51Agent(
|
73 |
+
env_id="PongNoFrameskip-v4", exp_name="PongNoFrameskip-v4-C51", cfg=cfg.exp_config, policy_state_dict=policy_state_dict
|
74 |
+
)
|
75 |
+
# Continue training
|
76 |
+
agent.train(step=5000)
|
77 |
+
# Render the new agent performance
|
78 |
+
agent.deploy(enable_save_replay=True)
|
79 |
+
|
80 |
```
|
81 |
</details>
|
82 |
|
|
|
91 |
```
|
92 |
**run.py**
|
93 |
```python
|
94 |
+
from ding.bonus import C51Agent
|
95 |
+
from huggingface_ding import pull_model_from_hub
|
96 |
+
|
97 |
+
# Pull model from Hugggingface hub
|
98 |
+
policy_state_dict, cfg = pull_model_from_hub(repo_id="OpenDILabCommunity/PongNoFrameskip-v4-C51")
|
99 |
+
# Instantiate the agent
|
100 |
+
agent = C51Agent(
|
101 |
+
env_id="PongNoFrameskip-v4", exp_name="PongNoFrameskip-v4-C51", cfg=cfg.exp_config, policy_state_dict=policy_state_dict
|
102 |
+
)
|
103 |
+
# Continue training
|
104 |
+
agent.train(step=5000)
|
105 |
+
# Render the new agent performance
|
106 |
+
agent.deploy(enable_save_replay=True)
|
107 |
+
|
108 |
```
|
109 |
</details>
|
110 |
|
|
|
121 |
```
|
122 |
**train.py**
|
123 |
```python
|
124 |
+
from ding.bonus import C51Agent
|
125 |
+
from huggingface_ding import push_model_to_hub
|
126 |
+
|
127 |
+
# Instantiate the agent
|
128 |
+
agent = C51Agent(env_id="PongNoFrameskip-v4", exp_name="PongNoFrameskip-v4-C51")
|
129 |
+
# Train the agent
|
130 |
+
return_ = agent.train(step=int(20000000))
|
131 |
+
# Push model to huggingface hub
|
132 |
+
push_model_to_hub(
|
133 |
+
agent=agent.best,
|
134 |
+
env_name="OpenAI/Gym/Atari",
|
135 |
+
task_name="PongNoFrameskip-v4",
|
136 |
+
algo_name="C51",
|
137 |
+
wandb_url=return_.wandb_url,
|
138 |
+
github_repo_url="https://github.com/opendilab/DI-engine",
|
139 |
+
github_doc_model_url="https://di-engine-docs.readthedocs.io/en/latest/12_policies/c51.html",
|
140 |
+
github_doc_env_url="https://di-engine-docs.readthedocs.io/en/latest/13_envs/atari.html",
|
141 |
+
installation_guide="pip3 install DI-engine[common_env]",
|
142 |
+
usage_file_by_git_clone="./c51/pong_c51_deploy.py",
|
143 |
+
usage_file_by_huggingface_ding="./c51/pong_c51_download.py",
|
144 |
+
train_file="./c51/pong_c51.py",
|
145 |
+
repo_id="OpenDILabCommunity/PongNoFrameskip-v4-C51",
|
146 |
+
create_repo=False
|
147 |
+
)
|
148 |
+
|
149 |
```
|
150 |
</details>
|
151 |
|
|
|
167 |
'retry_waiting_time': 0.1,
|
168 |
'cfg_type': 'BaseEnvManagerDict'
|
169 |
},
|
170 |
+
'stop_value': 30,
|
171 |
'n_evaluator_episode': 8,
|
172 |
'collector_env_num': 8,
|
173 |
'evaluator_env_num': 8,
|
|
|
219 |
'mode': 'train_iter'
|
220 |
},
|
221 |
'figure_path': None,
|
222 |
+
'return_env_info': True,
|
223 |
'cfg_type': 'InteractionSerialEvaluatorDict',
|
224 |
+
'stop_value': 30,
|
225 |
'n_episode': 8
|
226 |
}
|
227 |
},
|
|
|
264 |
|
265 |
**Training Procedure**
|
266 |
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
267 |
+
- **Weights & Biases (wandb):** [monitor link](https://wandb.ai/zjowowen/PongNoFrameskip-v4-C51)
|
268 |
|
269 |
## Model Information
|
270 |
<!-- Provide the basic links for the model. -->
|
|
|
274 |
- **Demo:** [video](https://huggingface.co/OpenDILabCommunity/PongNoFrameskip-v4-C51/blob/main/replay.mp4)
|
275 |
<!-- Provide the size information for the model. -->
|
276 |
- **Parameters total size:** 55276.2 KB
|
277 |
+
- **Last Update Date:** 2023-08-09
|
278 |
|
279 |
## Environments
|
280 |
<!-- 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. -->
|