document play.sh options

This commit is contained in:
wassname
2023-11-18 16:32:59 +08:00
parent a341e7aaad
commit 9b399031ca
3 changed files with 12 additions and 11 deletions
+7 -7
View File
@@ -14,22 +14,22 @@ while [ "$1" != "" ]; do
;;
-h | --header )
header=1
;;
;; # adds banner with env metadata like action
-r | --reconstruction )
reconstruction=1
;;
;; # 3 panes [original_obs, resized_obs, reconstructed], doesn't do anything if any of -w -a or -e are set. shows quality of encoder decoder
-s | --save-mode )
save_mode=1
;;
;; # lets you save the episode to mp4
-a | --agent-world-model )
mode="agent_in_world_model"
;;
;; # the agent plays in the world model env, shows the quality of the dynamics model
-e | --episode )
mode="episode_replay"
;;
;; # replay train, test, or imagined episodes. shows quality of dynamics model
-w | --world-model )
mode="play_in_world_model"
;;
;; # human plays in world model
* )
echo Invalid usage : $1
exit 1
@@ -37,4 +37,4 @@ while [ "$1" != "" ]; do
shift
done
python src/play.py hydra.run.dir=. hydra.output_subdir=null +mode="${mode}" +fps="${fps}" +header="${header}" +reconstruction="${reconstruction}" +save_mode="${save_mode}"
python -m pdb src/play.py hydra.run.dir=. hydra.output_subdir=null +mode="${mode}" +fps="${fps}" +header="${header}" +reconstruction="${reconstruction}" +save_mode="${save_mode}"
+1
View File
@@ -39,6 +39,7 @@ def make_crafter(id, size=64, max_episode_steps=None, done_on_life_loss=False):
# https://github.com/danijar/dreamerv2/blob/07d906e9c4322c6fc2cd6ed23e247ccd6b7c8c41/dreamerv2/common/envs.py#L242
# https://github.com/footoredo/torchbeast/blob/12939569cc46b6a8616e4c25b138d97248cc8581/torchbeast/atari_wrappers.py#L301
env = gym.make(id)
env = ResizeObsWrapper(env, (size, size))
return env
+4 -4
View File
@@ -4,14 +4,14 @@ from PIL import Image
import torch
from torchvision.transforms.functional import InterpolationMode, resize
from agent import Agent
from envs import SingleProcessEnv, WorldModelEnv
from game.keymap import get_keymap_and_action_names
from src.agent import Agent
from src.envs import SingleProcessEnv, WorldModelEnv
from src.game.keymap import get_keymap_and_action_names
class AgentEnv:
def __init__(self, agent: Agent, env: SingleProcessEnv, keymap_name: str, do_reconstruction: bool) -> None:
assert isinstance(env, SingleProcessEnv) or isinstance(env, WorldModelEnv)
assert isinstance(env, SingleProcessEnv) or isinstance(env, WorldModelEnv), f"{env}"
self.agent = agent
self.env = env
_, self.action_names = get_keymap_and_action_names(keymap_name)