Skip to content

Commit

Permalink
feat: add record video option in enjoy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin18 committed Dec 3, 2023
1 parent f33506d commit 402c92c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scripts/enjoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ def parse_args() -> argparse.Namespace:
default=42,
help="random generator seed",
)
parser.add_argument(
"--record-video",
action="store_true",
help="flag to record videos of episodes",
)
parser.add_argument(
"--video-folder",
default="videos",
help="path to videos folder",
)
args = parser.parse_args()
return args

Expand Down Expand Up @@ -96,6 +106,14 @@ def enjoy() -> None:

np.random.seed(args.seed)
env = gym.make(args.env, render_mode="human")
if args.record_video:
env = gym.wrappers.RecordVideo(
env,
video_folder=args.video_folder,
episode_trigger=lambda _: True,
disable_logger=True,
)

policy = make_policy(algo=args.algo, trained_agent=args.trained_agent)

for _ in trange(args.n_episodes, desc="Enjoy"):
Expand Down

0 comments on commit 402c92c

Please sign in to comment.