@@ -171,6 +171,66 @@ The `run-eval-post-training` command evaluates a range of checkpoints in paralle
171171In both cases environment and arguments as well as policy and arguments and wandb config for logging can be passed as CLI arguments.
172172
173173
174+ ## Adding your own environment
175+ ``` python
176+ from vlagents.evaluator_envs import EvaluatorEnv, Obs, Act
177+ from typing import Any
178+
179+ class YourEnv (EvaluatorEnv ):
180+
181+ def translate_obs (self , obs : dict[str , Any]) -> Obs:
182+ # translated your observation
183+ return Obs()
184+
185+ def step (self , action : Act) -> tuple[Obs, float , bool , bool , dict ]:
186+ # step your env
187+ obs, reward, success, truncated, info = self .env.step(action)
188+ return self .translate_obs(obs), reward, success, truncated, info
189+
190+ def reset (self , seed : int | None = None , options : dict[str , Any] | None = None ) -> tuple[Obs, dict[str , Any]]:
191+ obs, info = self .env.reset()
192+ return self .translate_obs(obs), info
193+
194+ @ property
195+ def language_instruction (self ) -> str :
196+ # return task instruction
197+ return " pick up the cube"
198+
199+ @ staticmethod
200+ def do_import ():
201+ # do imports required by your env
202+ import libero
203+
204+ EvaluatorEnv.register(" your-env-id" , YourEnv)
205+ ```
206+
207+ ## Adding your own policy
208+ ``` python
209+ from vlagents.policies import Agent, AGENTS
210+ from vlagents.evaluator_envs import Obs, Act
211+ from typing import Any
212+ import numpy as np
213+
214+ class YourAgent (Agent ):
215+ def initialize (self ):
216+ # heavy initialization, e.g. loading models
217+ pass
218+
219+ def act (self , obs : Obs) -> Act:
220+ # your forward pass
221+ return Act(action = np.zeros(7 , dtype = np.float32), done = False , info = {})
222+
223+ def reset (self , obs : Obs, instruction : Any, ** kwargs ) -> dict[str , Any]:
224+ # reset model if it has state and return info dict
225+ return {}
226+
227+ def close (self , * args , ** kwargs ):
228+ pass
229+ AGENTS [" your-agent-id" ] = YourAgent
230+ ```
231+
232+
233+
174234## Contribution
175235
176236### New Policy
0 commit comments