Skip to content

Commit

Permalink
loading saved models for rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
AGKhalil committed Jun 20, 2019
1 parent d92147d commit 816cd77
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions just_play.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import subprocess
import sys

if __name__ == "__main__":
model_name = str(sys.argv[1])

subprocess.Popen(
'''export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so:/usr/lib/nvidia-410/libGL.so; python load_agent.py '%s' ''' % model_name, shell=True)
32 changes: 32 additions & 0 deletions load_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
import sys
import gym
import gym_real
import numpy as np
import matplotlib.pyplot as plt
import datetime
from stable_baselines.common.policies import MlpPolicy
from stable_baselines.common.vec_env import SubprocVecEnv, DummyVecEnv
from stable_baselines import PPO2
from stable_baselines.bench import Monitor
from stable_baselines.results_plotter import load_results, ts2xy

if __name__ == "__main__":
file_name = str(sys.argv[1])

if file_name[:3] == "mod":
model_name = file_name
else:
dirpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "models")
log_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "tmp")
model_name = os.path.join(dirpath, file_name)

env_name = 'Real-v0'
env = gym.make(env_name)
model = PPO2.load(model_name)

obs = env.reset()
for i in range(1000):
action, _states = model.predict(obs)
obs, rewards, dones, info = env.step(action)
env.render()

0 comments on commit 816cd77

Please sign in to comment.