Downloads · 30 days
0
shenkexian/parking-env-model
parking-env-model is a reinforcement learning model from shenkexian. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. It is set up for parking-env. The card lists the license as mit.
Here are trained models of RL agents playing Parking-v0.
Downloads · 30 days
0
Access
Public
Updated Sep 13, 2023
Repo size
60.2 MB
Likes
0
Public
Click a slice to open those files.
.pth60.2 MB · 100%
From the Hugging Face model README
Here are trained models of RL agents playing Parking-v0.
git clone https://github.com/KexianShen/parking-env.git
cd parking-env
pip install -e .
import gymnasium as gym
import numpy as np
import torch
from parking_ppo import Agent
env = gym.make(
id="Parking-v0", render_mode="human", observation_type="rgb", action_type="discrete"
)
env = gym.wrappers.GrayScaleObservation(env)
env = gym.wrappers.FrameStack(env, 4)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
agent = torch.load("ppo.pth").eval().to(device)
obs, _ = env.reset(seed=42)
terminated = False
truncated = False
while not terminated and not truncated:
obs = torch.Tensor(np.array(obs)).to(device).unsqueeze(0)
with torch.no_grad():
action, _, _, _ = agent.get_action_and_value(obs)
action = action.cpu().numpy().item()
obs, reward, terminated, truncated, info = env.step(action)
env.close()