This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gymnasium as gym | |
import numpy as np | |
from gymnasium.envs.mujoco.mujoco_env import MujocoEnv | |
# Env initialization | |
env = gym.make("Swimmer-v4", render_mode="human") | |
# Wrap to have reward statistics | |
env = gym.wrappers.RecordEpisodeStatistics(env) | |
mujoco_env = env.unwrapped | |
n_joints = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gymnasium as gym | |
import numpy as np | |
from gymnasium.envs.mujoco.mujoco_env import MujocoEnv | |
# Env initialization | |
env = gym.make("HalfCheetah-v4", render_mode="human") | |
# Wrap to have reward statistics | |
env = gym.wrappers.RecordEpisodeStatistics(env) | |
mujoco_env = env.unwrapped | |
n_joints = 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import cv2 | |
import numpy as np | |
# Input Image | |
image = cv2.imread("my_image.jpg") | |
# Convert to HSV color space | |
hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV) | |
# Define range of white color in HSV | |
lower_white = np.array([0, 0, 212]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From https://github.com/araffin/python-arduino-serial | |
from robust_serial import Order, write_order, write_i8, write_i16 | |
from robust_serial.utils import open_serial_port | |
# Open serial port with a baudrate of 9600 (bits/s) | |
serial_file = open_serial_port(baudrate=9600) | |
# Send the order "MOTOR", i.e. to change the speed of the car | |
# equivalent to write_i8(serial_file, Order.MOTOR.value) | |
write_order(serial_file, Order.MOTOR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/datalogix/google-fonts-helper | |
// npm install google-fonts-helper | |
import { download } from 'google-fonts-helper' | |
const downloader = download('https://fonts.googleapis.com/css?family=Montserrat:400,700%7CRoboto:400,400italic,700%7CRoboto+Mono&display=swap', { | |
base64: false, | |
overwriting: false, | |
outputDir: './', | |
stylePath: 'fonts.css', | |
fontsDir: 'fonts', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gym | |
from stable_baselines import A2C | |
from stable_baselines.common.policies import MlpPolicy | |
from stable_baselines.common.vec_env import DummyVecEnv | |
# Create and wrap the environment | |
env = gym.make('LunarLander-v2') | |
env = DummyVecEnv([lambda: env]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gym | |
import numpy as np | |
import cma | |
from collections import OrderedDict | |
from stable_baselines import A2C | |
def flatten(params): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://github.com/hill-a/stable-baselines | |
import gym | |
from stable_baselines.common.policies import MlpPolicy | |
from stable_baselines import PPO2 | |
env = gym.make('CartPole-v1') | |
model = PPO2(MlpPolicy, env, verbose=1) | |
# Train the agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
import numpy as np | |
from stable_baselines import A2C, ACER, ACKTR, DQN, DDPG, PPO1, PPO2, TRPO | |
from stable_baselines.common import set_global_seeds | |
MODEL_LIST_DISCRETE = [ | |
A2C, | |
ACER, | |
ACKTR, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gym | |
import numpy as np | |
from stable_baselines.common.policies import MlpPolicy | |
from stable_baselines.common.vec_env import SubprocVecEnv | |
from stable_baselines.common import set_global_seeds | |
from stable_baselines import ACKTR | |
def make_env(env_id, rank, seed=0): | |
""" |
NewerOlder