Spaces:
Runtime error
Runtime error
Commit ·
fd6fab8
1
Parent(s): 69e0749
trying 300k BipedalWalker model default parameters
Browse files
app.py
CHANGED
|
@@ -1,12 +1,25 @@
|
|
| 1 |
-
import
|
|
|
|
| 2 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
st.write("Streamlit version:", st.__version__)
|
|
|
|
| 1 |
+
import glob
|
| 2 |
+
import gym
|
| 3 |
import time
|
| 4 |
+
import streamlit as st
|
| 5 |
+
from stable_baselines3 import PPO
|
| 6 |
+
|
| 7 |
+
env = gym.make('BipedalWalker-v3')
|
| 8 |
+
model = PPO.load("bipedalwalker_ppo")
|
| 9 |
+
|
| 10 |
+
video_every = 1
|
| 11 |
+
env = gym.wrappers.Monitor(env, "./video", video_callable=lambda episode_id: (episode_id%video_every)==0, force=True)
|
| 12 |
|
| 13 |
+
env.reset()
|
| 14 |
+
for i in range(1000):
|
| 15 |
+
action, _ = model.predict(obs, deterministic=True)
|
| 16 |
+
obs,reward,done,info =env.step(action)
|
| 17 |
+
# time.sleep(0.01)
|
| 18 |
+
if done :
|
| 19 |
+
env.reset()
|
| 20 |
+
env.close()
|
| 21 |
|
| 22 |
+
mp4_files = glob.glob("./video" + "/*.mp4")
|
| 23 |
+
video_file = open(mp4_files[-1], 'rb')
|
| 24 |
+
video_bytes = video_file.read()
|
| 25 |
+
st.video(video_bytes, format='mp4')
|
|
|