first-space / app.py
Energetic26's picture
removed absolute path, put rel path
e882d38
Raw History Blame Contribute Delete
965 Bytes
import gymnasium as gym
import streamlit as st
# import cv2
st.write(st.__version__ + "omg")
# env = gym.make("CartPole-v1", render_mode='rgb_array')
# observation, info = env.reset(seed=42)
# rgb_array = []
# for _ in range(1000):
# action = env.action_space.sample()
# observation, reward, terminated, truncated, info = env.step(action)
# rgb_array.append(env.render())
# if terminated or truncated:
# observation, info = env.reset()
# env.close()
# fourcc = cv2.VideoWriter_fourcc(*'mp4v')
# out = cv2.VideoWriter('output.mp4', fourcc, 60.0, (rgb_array[0].shape[1], rgb_array[0].shape[0]))
# # Write each frame to the video
# for i in range(len(rgb_array)):
# frame = rgb_array[i][:, :, ::-1] # Convert RGB to BGR
# out.write(frame)
# # Release everything if job is finished
# out.release()
# video_file = open('.\output.mp4', 'rb')
# st.video(video_file.read())
with open("output.mp4", 'rb') as v:
st.video(v.read())