Spaces:
Runtime error
Runtime error
Download app.py from Energetic26/first-space: direct link, hf CLI and curl.
- Browser
- Download file 965 Bytes
-
https://huggingface.co/spaces/Energetic26/first-space/resolve/main/app.py
- Command line
-
hf download hf://spaces/Energetic26/first-space/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Energetic26/first-space/resolve/main/app.py
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()) |