diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a5a8dfab0838dfe48d177810e1471ca8ee2b62e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,134 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +runs +wandb +models + + +# fichier mac +.DS_Store + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/CartPole-v1.zip b/CartPole-v1.zip new file mode 100644 index 0000000000000000000000000000000000000000..1355eae9b2f1eaca9ad3792c740ff7331587c03d Binary files /dev/null and b/CartPole-v1.zip differ diff --git a/README.md b/README.md index 29da3e74e8aed76ea80f93dc1225dfeb83e45bea..1d483f66cd54c1d586b0147a4168c7ea459c3d2b 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,8 @@ Link to the model on the hub : # REINFORCE Plot showing the total reward accross episodes:  + +# A2C trained model +Link to the trained model (available on huggingFace): https://huggingface.co/oscarchaufour/a2c-CartPole-v1 + + diff --git a/a2c_sb3_cartpole.py b/a2c_sb3_cartpole.py index d5090b4b11bf11d82f20f0e94b7a2a883e29e44c..9a1a519360c47cdc8bc7d4591c6f38649cad2339 100644 --- a/a2c_sb3_cartpole.py +++ b/a2c_sb3_cartpole.py @@ -1,53 +1,69 @@ -import gymnasium as gym +import gym import cv2 from stable_baselines3 import A2C from huggingface_sb3 import package_to_hub, push_to_hub from gym import envs from gymnasium.envs.registration import register from tqdm import tqdm +import matplotlib.pyplot as plt +import wandb +from wandb.integration.sb3 import WandbCallback +from stable_baselines3.common.vec_env import VecVideoRecorder +import dill +import zipfile +# Initialize Weights & Biases +total_timesteps = 10000 +config = { + "policy_type": "MlpPolicy", + "total_timesteps": total_timesteps, + "env_name": "CartPole-v1", +} +wandb.login() +run = wandb.init( + project="a2c-cartpole-v1", + config=config, + sync_tensorboard=True, # auto-upload sb3's tensorboard metrics + monitor_gym=True, # auto-upload the videos of agents playing the game + save_code=True, # optional +) env_id = "CartPole-v1" # Register the environment register(id=env_id, entry_point='gym.envs.classic_control:CartPoleEnv', max_episode_steps=500) env = gym.make(env_id) +# env = VecVideoRecorder( +# env, +# f"videos/{run.id}", +# record_video_trigger=lambda x: x % 2000 == 0, +# video_length=200, +# ) -model = A2C("MlpPolicy", env, verbose=1) -model.learn(total_timesteps=10_000) +model = A2C("MlpPolicy", env, verbose=1, tensorboard_log=f"runs/{run.id}") +model.learn(total_timesteps=total_timesteps, callback=WandbCallback( + gradient_save_freq=100, + model_save_path=f"models/{run.id}")) + + +# Mark the run as public in W&B project settings +run.finish() vec_env = model.get_env() obs = vec_env.reset() + for i in tqdm(range(1000)): action, _state = model.predict(obs, deterministic=True) obs, reward, done, info = vec_env.step(action) - vec_env.render("human") - - -####### TO BE DONE ####### - -# # Serialize the model and save it to a .zip file -# import pickle -# import zipfile - -# # Step 1: Serialize the model -# model_bytes = pickle.dumps(model) - -# # Step 2: Create a .zip file containing the serialized model -# zip_filename = env_id + ".zip" -# with zipfile.ZipFile(zip_filename, 'w') as zipf: -# zipf.writestr("model.pkl", model_bytes) - -# # Package and push the model to the Hugging Face Hub -# model_package_id = package_to_hub(model=model, -# model_name="a2c-CartPole-v1", -# model_architecture="a2c", -# env_id=env_id, -# eval_env=env, -# repo_id="oscarchaufour/a2c-CartPole-v1", -# commit_message="Initial commit of A2C CartPole model") - -# # Push the model package to the Hub -# push_to_hub(repo_id="oscarchaufour/a2c-CartPole-v1", -# filename=model_package_id + ".zip", -# commit_message="Added A2C CartPole model") \ No newline at end of file + vec_env.render() + +def save_model(model, env_id): + # Step 1: Serialize the model + model_bytes = dill.dumps(model) + + # Step 2: Create a .zip file containing the serialized model + zip_filename = env_id + ".zip" + with zipfile.ZipFile(zip_filename, 'w') as zipf: + zipf.writestr("model.pkl", model_bytes) + + diff --git a/images/reinforce_rewards.png b/images/reinforce_rewards.png index e76d632e17aa3bc917cd5e2de89c865baaeb0bcf..ad6ae6f4dcc6382e3da610e49588c4b51e50ccbd 100644 Binary files a/images/reinforce_rewards.png and b/images/reinforce_rewards.png differ diff --git a/neural_network_model.zip b/neural_network_model.zip deleted file mode 100644 index ba6de9a0b83bb0d2cf55768c2497c4f1a0e9345c..0000000000000000000000000000000000000000 Binary files a/neural_network_model.zip and /dev/null differ diff --git a/reinforce_cartpole.py b/reinforce_cartpole.py index bf5d1bb07e35868c96494835dad522ff77b29a78..ec767d8c70601339546b0d17c433cce76900af34 100644 --- a/reinforce_cartpole.py +++ b/reinforce_cartpole.py @@ -95,7 +95,7 @@ def plot_rewards(episodes_rewards): if __name__ == "__main__": # Create the environment - env = gym.make("CartPole-v1") + env = gym.make("CartPole-v1", render_mode="human") # Set up the agent policy = Policy( diff --git a/test.ipynb b/test.ipynb deleted file mode 100644 index 8a16e6581015df166f4ea76288d775d5fc00158f..0000000000000000000000000000000000000000 --- a/test.ipynb +++ /dev/null @@ -1,769 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# TD 1 : Hands-On Reinforcement Learning" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Packages download" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting pytorch\n", - " Downloading pytorch-1.0.2.tar.gz (689 bytes)\n", - " Installing build dependencies: started\n", - " Installing build dependencies: finished with status 'done'\n", - " Getting requirements to build wheel: started\n", - " Getting requirements to build wheel: finished with status 'done'\n", - " Installing backend dependencies: started\n", - " Installing backend dependencies: finished with status 'done'\n", - " Preparing metadata (pyproject.toml): started\n", - " Preparing metadata (pyproject.toml): finished with status 'done'\n", - "Building wheels for collected packages: pytorch\n", - " Building wheel for pytorch (pyproject.toml): started\n", - " Building wheel for pytorch (pyproject.toml): finished with status 'error'\n", - "Failed to build pytorch\n", - "Note: you may need to restart the kernel to use updated packages.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " error: subprocess-exited-with-error\n", - " \n", - " × Building wheel for pytorch (pyproject.toml) did not run successfully.\n", - " │ exit code: 1\n", - " ╰─> [20 lines of output]\n", - " Traceback (most recent call last):\n", - " File \"c:\\Users\\oscar\\Documents\\GitHub\\mso_3_4-td1\\.venv\\Lib\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process\\_in_process.py\", line 353, in <module>\n", - " main()\n", - " File \"c:\\Users\\oscar\\Documents\\GitHub\\mso_3_4-td1\\.venv\\Lib\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process\\_in_process.py\", line 335, in main\n", - " json_out['return_val'] = hook(**hook_input['kwargs'])\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"c:\\Users\\oscar\\Documents\\GitHub\\mso_3_4-td1\\.venv\\Lib\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process\\_in_process.py\", line 251, in build_wheel\n", - " return _build_backend().build_wheel(wheel_directory, config_settings,\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"C:\\Users\\oscar\\AppData\\Local\\Temp\\pip-build-env-onf33rce\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py\", line 404, in build_wheel\n", - " return self._build_with_temp_dir(\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"C:\\Users\\oscar\\AppData\\Local\\Temp\\pip-build-env-onf33rce\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py\", line 389, in _build_with_temp_dir\n", - " self.run_setup()\n", - " File \"C:\\Users\\oscar\\AppData\\Local\\Temp\\pip-build-env-onf33rce\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py\", line 480, in run_setup\n", - " super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)\n", - " File \"C:\\Users\\oscar\\AppData\\Local\\Temp\\pip-build-env-onf33rce\\overlay\\Lib\\site-packages\\setuptools\\build_meta.py\", line 311, in run_setup\n", - " exec(code, locals())\n", - " File \"<string>\", line 15, in <module>\n", - " Exception: You tried to install \"pytorch\". The package named for PyTorch is \"torch\"\n", - " [end of output]\n", - " \n", - " note: This error originates from a subprocess, and is likely not a problem with pip.\n", - " ERROR: Failed building wheel for pytorch\n", - "ERROR: Could not build wheels for pytorch, which is required to install pyproject.toml-based projects\n" - ] - } - ], - "source": [ - "pip install pytorch" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting gym==0.26.2Note: you may need to restart the kernel to use updated packages.\n", - "\n", - " Downloading gym-0.26.2.tar.gz (721 kB)\n", - " ---------------------------------------- 0.0/721.7 kB ? eta -:--:--\n", - " ---- ---------------------------------- 92.2/721.7 kB 2.6 MB/s eta 0:00:01\n", - " ------------ ------------------------- 235.5/721.7 kB 3.6 MB/s eta 0:00:01\n", - " ------------------ ------------------- 358.4/721.7 kB 2.8 MB/s eta 0:00:01\n", - " ------------------------- ------------ 481.3/721.7 kB 2.7 MB/s eta 0:00:01\n", - " -------------------------------- ----- 624.6/721.7 kB 2.8 MB/s eta 0:00:01\n", - " -------------------------------------- 721.7/721.7 kB 2.7 MB/s eta 0:00:00\n", - " Installing build dependencies: started\n", - " Installing build dependencies: finished with status 'done'\n", - " Getting requirements to build wheel: started\n", - " Getting requirements to build wheel: finished with status 'done'\n", - " Installing backend dependencies: started\n", - " Installing backend dependencies: finished with status 'done'\n", - " Preparing metadata (pyproject.toml): started\n", - " Preparing metadata (pyproject.toml): finished with status 'done'\n", - "Collecting numpy>=1.18.0 (from gym==0.26.2)\n", - " Downloading numpy-1.26.4-cp311-cp311-win_amd64.whl.metadata (61 kB)\n", - " ---------------------------------------- 0.0/61.0 kB ? eta -:--:--\n", - " --------------------------------- ------ 51.2/61.0 kB 1.3 MB/s eta 0:00:01\n", - " ---------------------------------------- 61.0/61.0 kB 1.1 MB/s eta 0:00:00\n", - "Collecting cloudpickle>=1.2.0 (from gym==0.26.2)\n", - " Downloading cloudpickle-3.0.0-py3-none-any.whl.metadata (7.0 kB)\n", - "Collecting gym-notices>=0.0.4 (from gym==0.26.2)\n", - " Downloading gym_notices-0.0.8-py3-none-any.whl (3.0 kB)\n", - "Downloading cloudpickle-3.0.0-py3-none-any.whl (20 kB)\n", - "Downloading numpy-1.26.4-cp311-cp311-win_amd64.whl (15.8 MB)\n", - " ---------------------------------------- 0.0/15.8 MB ? eta -:--:--\n", - " ---------------------------------------- 0.2/15.8 MB 5.9 MB/s eta 0:00:03\n", - " --------------------------------------- 0.3/15.8 MB 4.1 MB/s eta 0:00:04\n", - " - -------------------------------------- 0.4/15.8 MB 3.1 MB/s eta 0:00:05\n", - " - -------------------------------------- 0.5/15.8 MB 3.3 MB/s eta 0:00:05\n", - " - -------------------------------------- 0.5/15.8 MB 2.8 MB/s eta 0:00:06\n", - " - -------------------------------------- 0.7/15.8 MB 2.9 MB/s eta 0:00:06\n", - " - -------------------------------------- 0.7/15.8 MB 2.9 MB/s eta 0:00:06\n", - " -- ------------------------------------- 0.8/15.8 MB 2.5 MB/s eta 0:00:06\n", - " -- ------------------------------------- 0.9/15.8 MB 2.4 MB/s eta 0:00:07\n", - " -- ------------------------------------- 1.0/15.8 MB 2.2 MB/s eta 0:00:07\n", - " -- ------------------------------------- 1.0/15.8 MB 2.1 MB/s eta 0:00:08\n", - " -- ------------------------------------- 1.1/15.8 MB 2.1 MB/s eta 0:00:07\n", - " --- ------------------------------------ 1.2/15.8 MB 2.2 MB/s eta 0:00:07\n", - " --- ------------------------------------ 1.3/15.8 MB 2.2 MB/s eta 0:00:07\n", - " --- ------------------------------------ 1.5/15.8 MB 2.2 MB/s eta 0:00:07\n", - " --- ------------------------------------ 1.5/15.8 MB 2.1 MB/s eta 0:00:07\n", - " ---- ----------------------------------- 1.6/15.8 MB 2.2 MB/s eta 0:00:07\n", - " ---- ----------------------------------- 1.7/15.8 MB 2.1 MB/s eta 0:00:07\n", - " ---- ----------------------------------- 1.8/15.8 MB 2.2 MB/s eta 0:00:07\n", - " ----- ---------------------------------- 2.0/15.8 MB 2.3 MB/s eta 0:00:06\n", - " ----- ---------------------------------- 2.2/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ----- ---------------------------------- 2.3/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ------ --------------------------------- 2.4/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ------ --------------------------------- 2.5/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ------ --------------------------------- 2.6/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ------ --------------------------------- 2.7/15.8 MB 2.3 MB/s eta 0:00:06\n", - " ------- -------------------------------- 2.9/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ------- -------------------------------- 2.9/15.8 MB 2.3 MB/s eta 0:00:06\n", - " ------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06\n", - " ------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06\n", - " -------- ------------------------------- 3.3/15.8 MB 2.2 MB/s eta 0:00:06\n", - " -------- ------------------------------- 3.4/15.8 MB 2.2 MB/s eta 0:00:06\n", - " -------- ------------------------------- 3.5/15.8 MB 2.2 MB/s eta 0:00:06\n", - " --------- ------------------------------ 3.6/15.8 MB 2.2 MB/s eta 0:00:06\n", - " --------- ------------------------------ 3.6/15.8 MB 2.2 MB/s eta 0:00:06\n", - " --------- ------------------------------ 3.7/15.8 MB 2.2 MB/s eta 0:00:06\n", - " --------- ------------------------------ 3.7/15.8 MB 2.1 MB/s eta 0:00:06\n", - " --------- ------------------------------ 3.9/15.8 MB 2.1 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 4.0/15.8 MB 2.2 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 4.1/15.8 MB 2.2 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 4.1/15.8 MB 2.2 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 4.3/15.8 MB 2.2 MB/s eta 0:00:06\n", - " ----------- ---------------------------- 4.4/15.8 MB 2.2 MB/s eta 0:00:06\n", - " ----------- ---------------------------- 4.6/15.8 MB 2.2 MB/s eta 0:00:06\n", - " ----------- ---------------------------- 4.7/15.8 MB 2.3 MB/s eta 0:00:05\n", - " ------------ --------------------------- 4.8/15.8 MB 2.3 MB/s eta 0:00:05\n", - " ------------ --------------------------- 5.0/15.8 MB 2.3 MB/s eta 0:00:05\n", - " ------------ --------------------------- 5.1/15.8 MB 2.3 MB/s eta 0:00:05\n", - " ------------- -------------------------- 5.3/15.8 MB 2.3 MB/s eta 0:00:05\n", - " ------------- -------------------------- 5.4/15.8 MB 2.4 MB/s eta 0:00:05\n", - " ------------- -------------------------- 5.4/15.8 MB 2.3 MB/s eta 0:00:05\n", - " ------------- -------------------------- 5.5/15.8 MB 2.3 MB/s eta 0:00:05\n", - " -------------- ------------------------- 5.6/15.8 MB 2.3 MB/s eta 0:00:05\n", - " -------------- ------------------------- 5.8/15.8 MB 2.3 MB/s eta 0:00:05\n", - " -------------- ------------------------- 5.9/15.8 MB 2.3 MB/s eta 0:00:05\n", - " --------------- ------------------------ 6.0/15.8 MB 2.3 MB/s eta 0:00:05\n", - " --------------- ------------------------ 6.1/15.8 MB 2.3 MB/s eta 0:00:05\n", - " --------------- ------------------------ 6.2/15.8 MB 2.3 MB/s eta 0:00:05\n", - " ---------------- ----------------------- 6.4/15.8 MB 2.4 MB/s eta 0:00:05\n", - " ---------------- ----------------------- 6.4/15.8 MB 2.3 MB/s eta 0:00:05\n", - " ---------------- ----------------------- 6.6/15.8 MB 2.3 MB/s eta 0:00:04\n", - " ----------------- ---------------------- 6.7/15.8 MB 2.4 MB/s eta 0:00:04\n", - " ----------------- ---------------------- 7.0/15.8 MB 2.4 MB/s eta 0:00:04\n", - " ----------------- ---------------------- 7.1/15.8 MB 2.4 MB/s eta 0:00:04\n", - " ------------------ --------------------- 7.3/15.8 MB 2.4 MB/s eta 0:00:04\n", - " ------------------ --------------------- 7.5/15.8 MB 2.5 MB/s eta 0:00:04\n", - " ------------------- -------------------- 7.5/15.8 MB 2.4 MB/s eta 0:00:04\n", - " ------------------- -------------------- 7.7/15.8 MB 2.5 MB/s eta 0:00:04\n", - " ------------------- -------------------- 7.7/15.8 MB 2.5 MB/s eta 0:00:04\n", - " ------------------- -------------------- 7.9/15.8 MB 2.4 MB/s eta 0:00:04\n", - " -------------------- ------------------- 8.0/15.8 MB 2.5 MB/s eta 0:00:04\n", - " -------------------- ------------------- 8.2/15.8 MB 2.5 MB/s eta 0:00:04\n", - " --------------------- ------------------ 8.4/15.8 MB 2.5 MB/s eta 0:00:03\n", - " --------------------- ------------------ 8.5/15.8 MB 2.5 MB/s eta 0:00:03\n", - " --------------------- ------------------ 8.7/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ---------------------- ----------------- 8.8/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ----------------------- ---------------- 9.1/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ----------------------- ---------------- 9.2/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ----------------------- ---------------- 9.3/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ----------------------- ---------------- 9.3/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ------------------------ --------------- 9.6/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ------------------------ --------------- 9.7/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ------------------------ --------------- 9.9/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ------------------------- -------------- 10.0/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ------------------------- -------------- 10.1/15.8 MB 2.6 MB/s eta 0:00:03\n", - " ------------------------- -------------- 10.2/15.8 MB 2.6 MB/s eta 0:00:03\n", - " -------------------------- ------------- 10.3/15.8 MB 2.6 MB/s eta 0:00:03\n", - " -------------------------- ------------- 10.5/15.8 MB 2.6 MB/s eta 0:00:03\n", - " -------------------------- ------------- 10.7/15.8 MB 2.6 MB/s eta 0:00:02\n", - " --------------------------- ------------ 10.8/15.8 MB 2.7 MB/s eta 0:00:02\n", - " ---------------------------- ----------- 11.1/15.8 MB 2.7 MB/s eta 0:00:02\n", - " ---------------------------- ----------- 11.3/15.8 MB 2.8 MB/s eta 0:00:02\n", - " ---------------------------- ----------- 11.4/15.8 MB 2.8 MB/s eta 0:00:02\n", - " ----------------------------- ---------- 11.6/15.8 MB 2.8 MB/s eta 0:00:02\n", - " ------------------------------ --------- 11.9/15.8 MB 2.9 MB/s eta 0:00:02\n", - " ------------------------------ --------- 12.1/15.8 MB 2.9 MB/s eta 0:00:02\n", - " ------------------------------- -------- 12.3/15.8 MB 2.9 MB/s eta 0:00:02\n", - " ------------------------------- -------- 12.5/15.8 MB 3.0 MB/s eta 0:00:02\n", - " -------------------------------- ------- 12.7/15.8 MB 3.0 MB/s eta 0:00:02\n", - " -------------------------------- ------- 12.9/15.8 MB 3.1 MB/s eta 0:00:01\n", - " --------------------------------- ------ 13.1/15.8 MB 3.1 MB/s eta 0:00:01\n", - " --------------------------------- ------ 13.4/15.8 MB 3.3 MB/s eta 0:00:01\n", - " ---------------------------------- ----- 13.6/15.8 MB 3.3 MB/s eta 0:00:01\n", - " ---------------------------------- ----- 13.7/15.8 MB 3.4 MB/s eta 0:00:01\n", - " ---------------------------------- ----- 13.8/15.8 MB 3.3 MB/s eta 0:00:01\n", - " ----------------------------------- ---- 14.0/15.8 MB 3.4 MB/s eta 0:00:01\n", - " ----------------------------------- ---- 14.1/15.8 MB 3.4 MB/s eta 0:00:01\n", - " ------------------------------------ --- 14.3/15.8 MB 3.5 MB/s eta 0:00:01\n", - " ------------------------------------ --- 14.5/15.8 MB 3.5 MB/s eta 0:00:01\n", - " ------------------------------------- -- 14.6/15.8 MB 3.5 MB/s eta 0:00:01\n", - " ------------------------------------- -- 14.9/15.8 MB 3.5 MB/s eta 0:00:01\n", - " ------------------------------------- -- 15.0/15.8 MB 3.5 MB/s eta 0:00:01\n", - " -------------------------------------- - 15.2/15.8 MB 3.6 MB/s eta 0:00:01\n", - " --------------------------------------- 15.4/15.8 MB 3.6 MB/s eta 0:00:01\n", - " --------------------------------------- 15.6/15.8 MB 3.6 MB/s eta 0:00:01\n", - " --------------------------------------- 15.8/15.8 MB 3.7 MB/s eta 0:00:01\n", - " ---------------------------------------- 15.8/15.8 MB 3.7 MB/s eta 0:00:00\n", - "Building wheels for collected packages: gym\n", - " Building wheel for gym (pyproject.toml): started\n", - " Building wheel for gym (pyproject.toml): finished with status 'done'\n", - " Created wheel for gym: filename=gym-0.26.2-py3-none-any.whl size=827629 sha256=73a686c8633b88e54b0477d643a4d44b9c28378813129811ee402183300c3525\n", - " Stored in directory: c:\\users\\oscar\\appdata\\local\\pip\\cache\\wheels\\1c\\77\\9e\\9af5470201a0b0543937933ee99ba884cd237d2faefe8f4d37\n", - "Successfully built gym\n", - "Installing collected packages: gym-notices, numpy, cloudpickle, gym\n", - "Successfully installed cloudpickle-3.0.0 gym-0.26.2 gym-notices-0.0.8 numpy-1.26.4\n" - ] - } - ], - "source": [ - "pip install gym==0.26.2" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting pyglet==2.0.10\n", - " Downloading pyglet-2.0.10-py3-none-any.whl.metadata (8.5 kB)\n", - "Downloading pyglet-2.0.10-py3-none-any.whl (858 kB)\n", - " ---------------------------------------- 0.0/858.3 kB ? eta -:--:--\n", - " ---------------------------------------- 0.0/858.3 kB ? eta -:--:--\n", - " ---------------------------------------- 0.0/858.3 kB ? eta -:--:--\n", - " - -------------------------------------- 30.7/858.3 kB ? eta -:--:--\n", - " - -------------------------------------- 30.7/858.3 kB ? eta -:--:--\n", - " - ------------------------------------- 41.0/858.3 kB 330.3 kB/s eta 0:00:03\n", - " ---- --------------------------------- 112.6/858.3 kB 595.3 kB/s eta 0:00:02\n", - " ---- --------------------------------- 112.6/858.3 kB 595.3 kB/s eta 0:00:02\n", - " ---- --------------------------------- 112.6/858.3 kB 595.3 kB/s eta 0:00:02\n", - " ----- -------------------------------- 122.9/858.3 kB 379.3 kB/s eta 0:00:02\n", - " ----- -------------------------------- 122.9/858.3 kB 379.3 kB/s eta 0:00:02\n", - " ------ ------------------------------- 143.4/858.3 kB 341.3 kB/s eta 0:00:03\n", - " -------- ----------------------------- 194.6/858.3 kB 472.6 kB/s eta 0:00:02\n", - " -------- ----------------------------- 194.6/858.3 kB 472.6 kB/s eta 0:00:02\n", - " -------- ----------------------------- 194.6/858.3 kB 472.6 kB/s eta 0:00:02\n", - " ----------- -------------------------- 256.0/858.3 kB 477.2 kB/s eta 0:00:02\n", - " ----------- -------------------------- 256.0/858.3 kB 477.2 kB/s eta 0:00:02\n", - " -------------- ----------------------- 327.7/858.3 kB 507.9 kB/s eta 0:00:02\n", - " --------------- ---------------------- 358.4/858.3 kB 495.2 kB/s eta 0:00:02\n", - " ----------------- -------------------- 389.1/858.3 kB 527.7 kB/s eta 0:00:01\n", - " ------------------- ------------------ 450.6/858.3 kB 563.8 kB/s eta 0:00:01\n", - " -------------------- ----------------- 460.8/858.3 kB 544.2 kB/s eta 0:00:01\n", - " ----------------------- -------------- 532.5/858.3 kB 596.8 kB/s eta 0:00:01\n", - " --------------------------- ---------- 614.4/858.3 kB 655.3 kB/s eta 0:00:01\n", - " ---------------------------- --------- 645.1/858.3 kB 677.6 kB/s eta 0:00:01\n", - " ------------------------------ ------- 686.1/858.3 kB 675.8 kB/s eta 0:00:01\n", - " --------------------------------- ---- 747.5/858.3 kB 704.2 kB/s eta 0:00:01\n", - " ----------------------------------- -- 798.7/858.3 kB 742.4 kB/s eta 0:00:01\n", - " -------------------------------------- 858.3/858.3 kB 753.8 kB/s eta 0:00:00\n", - "Installing collected packages: pyglet\n", - "Successfully installed pyglet-2.0.10\n", - "Note: you may need to restart the kernel to use updated packages.\n" - ] - } - ], - "source": [ - "pip install pyglet==2.0.10" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting pygame==2.5.2\n", - " Downloading pygame-2.5.2-cp311-cp311-win_amd64.whl.metadata (13 kB)\n", - "Downloading pygame-2.5.2-cp311-cp311-win_amd64.whl (10.8 MB)\n", - " ---------------------------------------- 0.0/10.8 MB ? eta -:--:--\n", - " ---------------------------------------- 0.1/10.8 MB 3.5 MB/s eta 0:00:04\n", - " --------------------------------------- 0.2/10.8 MB 3.7 MB/s eta 0:00:03\n", - " - -------------------------------------- 0.4/10.8 MB 3.9 MB/s eta 0:00:03\n", - " -- ------------------------------------- 0.7/10.8 MB 4.6 MB/s eta 0:00:03\n", - " --- ------------------------------------ 0.9/10.8 MB 4.6 MB/s eta 0:00:03\n", - " ---- ----------------------------------- 1.1/10.8 MB 5.1 MB/s eta 0:00:02\n", - " ---- ----------------------------------- 1.3/10.8 MB 5.2 MB/s eta 0:00:02\n", - " ----- ---------------------------------- 1.5/10.8 MB 5.0 MB/s eta 0:00:02\n", - " ------ --------------------------------- 1.8/10.8 MB 5.1 MB/s eta 0:00:02\n", - " ------- -------------------------------- 2.0/10.8 MB 5.2 MB/s eta 0:00:02\n", - " -------- ------------------------------- 2.3/10.8 MB 5.4 MB/s eta 0:00:02\n", - " --------- ------------------------------ 2.5/10.8 MB 5.2 MB/s eta 0:00:02\n", - " ---------- ----------------------------- 2.8/10.8 MB 5.4 MB/s eta 0:00:02\n", - " ----------- ---------------------------- 3.1/10.8 MB 5.7 MB/s eta 0:00:02\n", - " ----------- ---------------------------- 3.2/10.8 MB 5.6 MB/s eta 0:00:02\n", - " ------------ --------------------------- 3.4/10.8 MB 5.5 MB/s eta 0:00:02\n", - " ------------- -------------------------- 3.6/10.8 MB 5.2 MB/s eta 0:00:02\n", - " -------------- ------------------------- 3.9/10.8 MB 5.3 MB/s eta 0:00:02\n", - " --------------- ------------------------ 4.1/10.8 MB 5.2 MB/s eta 0:00:02\n", - " ---------------- ----------------------- 4.4/10.8 MB 5.3 MB/s eta 0:00:02\n", - " ----------------- ---------------------- 4.8/10.8 MB 5.5 MB/s eta 0:00:02\n", - " ------------------ --------------------- 5.1/10.8 MB 5.6 MB/s eta 0:00:02\n", - " ------------------- -------------------- 5.3/10.8 MB 5.6 MB/s eta 0:00:01\n", - " -------------------- ------------------- 5.6/10.8 MB 5.6 MB/s eta 0:00:01\n", - " --------------------- ------------------ 5.8/10.8 MB 5.6 MB/s eta 0:00:01\n", - " ---------------------- ----------------- 6.0/10.8 MB 5.6 MB/s eta 0:00:01\n", - " ----------------------- ---------------- 6.3/10.8 MB 5.6 MB/s eta 0:00:01\n", - " ------------------------ --------------- 6.7/10.8 MB 5.7 MB/s eta 0:00:01\n", - " ------------------------- -------------- 6.9/10.8 MB 5.8 MB/s eta 0:00:01\n", - " -------------------------- ------------- 7.2/10.8 MB 5.8 MB/s eta 0:00:01\n", - " --------------------------- ------------ 7.3/10.8 MB 5.6 MB/s eta 0:00:01\n", - " ---------------------------- ----------- 7.5/10.8 MB 5.7 MB/s eta 0:00:01\n", - " ----------------------------- ---------- 7.8/10.8 MB 5.7 MB/s eta 0:00:01\n", - " ----------------------------- ---------- 8.0/10.8 MB 5.6 MB/s eta 0:00:01\n", - " ------------------------------ --------- 8.2/10.8 MB 5.6 MB/s eta 0:00:01\n", - " ------------------------------- -------- 8.3/10.8 MB 5.6 MB/s eta 0:00:01\n", - " ------------------------------- -------- 8.5/10.8 MB 5.5 MB/s eta 0:00:01\n", - " -------------------------------- ------- 8.6/10.8 MB 5.3 MB/s eta 0:00:01\n", - " -------------------------------- ------- 8.8/10.8 MB 5.4 MB/s eta 0:00:01\n", - " --------------------------------- ------ 9.0/10.8 MB 5.4 MB/s eta 0:00:01\n", - " ---------------------------------- ----- 9.3/10.8 MB 5.4 MB/s eta 0:00:01\n", - " ------------------------------------ --- 9.8/10.8 MB 5.5 MB/s eta 0:00:01\n", - " ------------------------------------- -- 10.1/10.8 MB 5.5 MB/s eta 0:00:01\n", - " -------------------------------------- - 10.3/10.8 MB 5.5 MB/s eta 0:00:01\n", - " --------------------------------------- 10.5/10.8 MB 5.6 MB/s eta 0:00:01\n", - " --------------------------------------- 10.7/10.8 MB 5.7 MB/s eta 0:00:01\n", - " ---------------------------------------- 10.8/10.8 MB 5.5 MB/s eta 0:00:00\n", - "Installing collected packages: pygame\n", - "Successfully installed pygame-2.5.2\n", - "Note: you may need to restart the kernel to use updated packages.\n" - ] - } - ], - "source": [ - "pip install pygame==2.5.2" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting PyQt5Note: you may need to restart the kernel to use updated packages.\n", - "\n", - " Downloading PyQt5-5.15.10-cp37-abi3-win_amd64.whl.metadata (2.2 kB)\n", - "Collecting PyQt5-sip<13,>=12.13 (from PyQt5)\n", - " Downloading PyQt5_sip-12.13.0-cp311-cp311-win_amd64.whl.metadata (524 bytes)\n", - "Collecting PyQt5-Qt5>=5.15.2 (from PyQt5)\n", - " Downloading PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB)\n", - " ---------------------------------------- 0.0/50.1 MB ? eta -:--:--\n", - " ---------------------------------------- 0.1/50.1 MB 4.3 MB/s eta 0:00:12\n", - " ---------------------------------------- 0.4/50.1 MB 6.1 MB/s eta 0:00:09\n", - " --------------------------------------- 0.7/50.1 MB 5.9 MB/s eta 0:00:09\n", - " --------------------------------------- 0.9/50.1 MB 5.5 MB/s eta 0:00:09\n", - " --------------------------------------- 1.1/50.1 MB 5.7 MB/s eta 0:00:09\n", - " - -------------------------------------- 1.4/50.1 MB 5.9 MB/s eta 0:00:09\n", - " - -------------------------------------- 1.6/50.1 MB 6.1 MB/s eta 0:00:08\n", - " - -------------------------------------- 2.2/50.1 MB 6.6 MB/s eta 0:00:08\n", - " - -------------------------------------- 2.5/50.1 MB 6.5 MB/s eta 0:00:08\n", - " -- ------------------------------------- 2.8/50.1 MB 6.6 MB/s eta 0:00:08\n", - " -- ------------------------------------- 3.1/50.1 MB 6.8 MB/s eta 0:00:07\n", - " -- ------------------------------------- 3.2/50.1 MB 6.4 MB/s eta 0:00:08\n", - " -- ------------------------------------- 3.4/50.1 MB 6.3 MB/s eta 0:00:08\n", - " --- ------------------------------------ 3.8/50.1 MB 6.5 MB/s eta 0:00:08\n", - " --- ------------------------------------ 4.1/50.1 MB 6.6 MB/s eta 0:00:08\n", - " --- ------------------------------------ 4.5/50.1 MB 6.9 MB/s eta 0:00:07\n", - " --- ------------------------------------ 4.8/50.1 MB 6.8 MB/s eta 0:00:07\n", - " ---- ----------------------------------- 5.1/50.1 MB 6.9 MB/s eta 0:00:07\n", - " ---- ----------------------------------- 5.4/50.1 MB 6.9 MB/s eta 0:00:07\n", - " ---- ----------------------------------- 5.6/50.1 MB 6.8 MB/s eta 0:00:07\n", - " ---- ----------------------------------- 5.9/50.1 MB 6.7 MB/s eta 0:00:07\n", - " ---- ----------------------------------- 6.2/50.1 MB 6.7 MB/s eta 0:00:07\n", - " ----- ---------------------------------- 6.6/50.1 MB 6.8 MB/s eta 0:00:07\n", - " ----- ---------------------------------- 6.9/50.1 MB 6.8 MB/s eta 0:00:07\n", - " ----- ---------------------------------- 7.3/50.1 MB 6.8 MB/s eta 0:00:07\n", - " ----- ---------------------------------- 7.4/50.1 MB 6.7 MB/s eta 0:00:07\n", - " ------ --------------------------------- 7.6/50.1 MB 6.6 MB/s eta 0:00:07\n", - " ------ --------------------------------- 7.9/50.1 MB 6.8 MB/s eta 0:00:07\n", - " ------ --------------------------------- 8.3/50.1 MB 6.8 MB/s eta 0:00:07\n", - " ------ --------------------------------- 8.7/50.1 MB 6.9 MB/s eta 0:00:06\n", - " ------- -------------------------------- 9.1/50.1 MB 6.8 MB/s eta 0:00:06\n", - " ------- -------------------------------- 9.5/50.1 MB 6.9 MB/s eta 0:00:06\n", - " ------- -------------------------------- 9.7/50.1 MB 6.9 MB/s eta 0:00:06\n", - " ------- -------------------------------- 10.0/50.1 MB 6.9 MB/s eta 0:00:06\n", - " -------- ------------------------------- 10.2/50.1 MB 6.8 MB/s eta 0:00:06\n", - " -------- ------------------------------- 10.4/50.1 MB 6.7 MB/s eta 0:00:06\n", - " -------- ------------------------------- 10.7/50.1 MB 6.9 MB/s eta 0:00:06\n", - " -------- ------------------------------- 10.8/50.1 MB 6.7 MB/s eta 0:00:06\n", - " -------- ------------------------------- 11.1/50.1 MB 6.8 MB/s eta 0:00:06\n", - " --------- ------------------------------ 11.4/50.1 MB 6.8 MB/s eta 0:00:06\n", - " --------- ------------------------------ 11.5/50.1 MB 6.7 MB/s eta 0:00:06\n", - " --------- ------------------------------ 11.8/50.1 MB 6.7 MB/s eta 0:00:06\n", - " --------- ------------------------------ 12.0/50.1 MB 6.6 MB/s eta 0:00:06\n", - " --------- ------------------------------ 12.3/50.1 MB 6.6 MB/s eta 0:00:06\n", - " --------- ------------------------------ 12.5/50.1 MB 6.4 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 12.7/50.1 MB 6.4 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 13.0/50.1 MB 6.4 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 13.1/50.1 MB 6.3 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 13.3/50.1 MB 6.3 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 13.4/50.1 MB 6.2 MB/s eta 0:00:06\n", - " ---------- ----------------------------- 13.5/50.1 MB 6.1 MB/s eta 0:00:07\n", - " ---------- ----------------------------- 13.6/50.1 MB 6.2 MB/s eta 0:00:06\n", - " ----------- ---------------------------- 13.8/50.1 MB 6.0 MB/s eta 0:00:07\n", - " ----------- ---------------------------- 14.0/50.1 MB 5.9 MB/s eta 0:00:07\n", - " ----------- ---------------------------- 14.2/50.1 MB 5.8 MB/s eta 0:00:07\n", - " ----------- ---------------------------- 14.4/50.1 MB 5.8 MB/s eta 0:00:07\n", - " ----------- ---------------------------- 14.8/50.1 MB 5.7 MB/s eta 0:00:07\n", - " ----------- ---------------------------- 15.0/50.1 MB 5.7 MB/s eta 0:00:07\n", - " ------------ --------------------------- 15.1/50.1 MB 5.7 MB/s eta 0:00:07\n", - " ------------ --------------------------- 15.2/50.1 MB 5.6 MB/s eta 0:00:07\n", - " ------------ --------------------------- 15.4/50.1 MB 5.5 MB/s eta 0:00:07\n", - " ------------ --------------------------- 15.6/50.1 MB 5.5 MB/s eta 0:00:07\n", - " ------------ --------------------------- 15.7/50.1 MB 5.5 MB/s eta 0:00:07\n", - " ------------ --------------------------- 15.9/50.1 MB 5.5 MB/s eta 0:00:07\n", - " ------------ --------------------------- 16.1/50.1 MB 5.4 MB/s eta 0:00:07\n", - " ------------ --------------------------- 16.2/50.1 MB 5.3 MB/s eta 0:00:07\n", - " ------------- -------------------------- 16.4/50.1 MB 5.3 MB/s eta 0:00:07\n", - " ------------- -------------------------- 16.7/50.1 MB 5.2 MB/s eta 0:00:07\n", - " ------------- -------------------------- 16.8/50.1 MB 5.2 MB/s eta 0:00:07\n", - " ------------- -------------------------- 17.0/50.1 MB 5.2 MB/s eta 0:00:07\n", - " ------------- -------------------------- 17.2/50.1 MB 5.1 MB/s eta 0:00:07\n", - " ------------- -------------------------- 17.4/50.1 MB 5.0 MB/s eta 0:00:07\n", - " -------------- ------------------------- 17.6/50.1 MB 5.1 MB/s eta 0:00:07\n", - " -------------- ------------------------- 17.8/50.1 MB 5.1 MB/s eta 0:00:07\n", - " -------------- ------------------------- 18.1/50.1 MB 5.0 MB/s eta 0:00:07\n", - " -------------- ------------------------- 18.3/50.1 MB 5.0 MB/s eta 0:00:07\n", - " -------------- ------------------------- 18.5/50.1 MB 4.9 MB/s eta 0:00:07\n", - " -------------- ------------------------- 18.5/50.1 MB 4.9 MB/s eta 0:00:07\n", - " -------------- ------------------------- 18.7/50.1 MB 4.8 MB/s eta 0:00:07\n", - " -------------- ------------------------- 18.8/50.1 MB 4.7 MB/s eta 0:00:07\n", - " --------------- ------------------------ 18.8/50.1 MB 4.7 MB/s eta 0:00:07\n", - " --------------- ------------------------ 19.0/50.1 MB 4.6 MB/s eta 0:00:07\n", - " --------------- ------------------------ 19.3/50.1 MB 4.6 MB/s eta 0:00:07\n", - " --------------- ------------------------ 19.4/50.1 MB 4.6 MB/s eta 0:00:07\n", - " --------------- ------------------------ 19.7/50.1 MB 4.5 MB/s eta 0:00:07\n", - " ---------------- ----------------------- 20.1/50.1 MB 4.6 MB/s eta 0:00:07\n", - " ---------------- ----------------------- 20.4/50.1 MB 4.6 MB/s eta 0:00:07\n", - " ---------------- ----------------------- 20.6/50.1 MB 4.6 MB/s eta 0:00:07\n", - " ---------------- ----------------------- 20.7/50.1 MB 4.6 MB/s eta 0:00:07\n", - " ---------------- ----------------------- 21.1/50.1 MB 4.6 MB/s eta 0:00:07\n", - " ----------------- ---------------------- 21.3/50.1 MB 4.6 MB/s eta 0:00:07\n", - " ----------------- ---------------------- 21.6/50.1 MB 4.6 MB/s eta 0:00:07\n", - " ----------------- ---------------------- 21.9/50.1 MB 4.7 MB/s eta 0:00:07\n", - " ----------------- ---------------------- 22.1/50.1 MB 4.6 MB/s eta 0:00:07\n", - " ----------------- ---------------------- 22.4/50.1 MB 4.7 MB/s eta 0:00:06\n", - " ------------------ --------------------- 22.7/50.1 MB 4.7 MB/s eta 0:00:06\n", - " ------------------ --------------------- 22.9/50.1 MB 4.7 MB/s eta 0:00:06\n", - " ------------------ --------------------- 23.1/50.1 MB 4.6 MB/s eta 0:00:06\n", - " ------------------ --------------------- 23.5/50.1 MB 4.7 MB/s eta 0:00:06\n", - " ------------------ --------------------- 23.6/50.1 MB 4.8 MB/s eta 0:00:06\n", - " ------------------ --------------------- 23.7/50.1 MB 4.8 MB/s eta 0:00:06\n", - " ------------------- -------------------- 23.9/50.1 MB 4.8 MB/s eta 0:00:06\n", - " ------------------- -------------------- 24.3/50.1 MB 4.9 MB/s eta 0:00:06\n", - " ------------------- -------------------- 24.5/50.1 MB 4.9 MB/s eta 0:00:06\n", - " ------------------- -------------------- 24.7/50.1 MB 4.9 MB/s eta 0:00:06\n", - " ------------------- -------------------- 24.9/50.1 MB 4.8 MB/s eta 0:00:06\n", - " ------------------- -------------------- 25.0/50.1 MB 4.7 MB/s eta 0:00:06\n", - " -------------------- ------------------- 25.1/50.1 MB 4.7 MB/s eta 0:00:06\n", - " -------------------- ------------------- 25.2/50.1 MB 4.7 MB/s eta 0:00:06\n", - " -------------------- ------------------- 25.4/50.1 MB 4.6 MB/s eta 0:00:06\n", - " -------------------- ------------------- 25.6/50.1 MB 4.7 MB/s eta 0:00:06\n", - " -------------------- ------------------- 25.7/50.1 MB 4.7 MB/s eta 0:00:06\n", - " -------------------- ------------------- 26.1/50.1 MB 4.8 MB/s eta 0:00:06\n", - " --------------------- ------------------ 26.3/50.1 MB 4.9 MB/s eta 0:00:05\n", - " --------------------- ------------------ 26.4/50.1 MB 4.8 MB/s eta 0:00:05\n", - " --------------------- ------------------ 26.7/50.1 MB 4.9 MB/s eta 0:00:05\n", - " --------------------- ------------------ 26.8/50.1 MB 4.9 MB/s eta 0:00:05\n", - " --------------------- ------------------ 27.0/50.1 MB 4.8 MB/s eta 0:00:05\n", - " --------------------- ------------------ 27.1/50.1 MB 4.9 MB/s eta 0:00:05\n", - " --------------------- ------------------ 27.4/50.1 MB 4.9 MB/s eta 0:00:05\n", - " ---------------------- ----------------- 27.7/50.1 MB 4.8 MB/s eta 0:00:05\n", - " ---------------------- ----------------- 27.9/50.1 MB 4.8 MB/s eta 0:00:05\n", - " ---------------------- ----------------- 28.2/50.1 MB 4.8 MB/s eta 0:00:05\n", - " ---------------------- ----------------- 28.3/50.1 MB 4.8 MB/s eta 0:00:05\n", - " ---------------------- ----------------- 28.6/50.1 MB 4.9 MB/s eta 0:00:05\n", - " ----------------------- ---------------- 28.8/50.1 MB 5.0 MB/s eta 0:00:05\n", - " ----------------------- ---------------- 29.0/50.1 MB 5.0 MB/s eta 0:00:05\n", - " ----------------------- ---------------- 29.3/50.1 MB 5.1 MB/s eta 0:00:05\n", - " ----------------------- ---------------- 29.6/50.1 MB 5.2 MB/s eta 0:00:04\n", - " ----------------------- ---------------- 29.7/50.1 MB 5.1 MB/s eta 0:00:04\n", - " ----------------------- ---------------- 29.9/50.1 MB 5.1 MB/s eta 0:00:04\n", - " ------------------------ --------------- 30.2/50.1 MB 5.1 MB/s eta 0:00:04\n", - " ------------------------ --------------- 30.4/50.1 MB 5.0 MB/s eta 0:00:04\n", - " ------------------------ --------------- 30.7/50.1 MB 5.1 MB/s eta 0:00:04\n", - " ------------------------ --------------- 31.0/50.1 MB 5.1 MB/s eta 0:00:04\n", - " ------------------------ --------------- 31.2/50.1 MB 5.1 MB/s eta 0:00:04\n", - " ------------------------- -------------- 31.5/50.1 MB 5.1 MB/s eta 0:00:04\n", - " ------------------------- -------------- 31.5/50.1 MB 5.1 MB/s eta 0:00:04\n", - " ------------------------- -------------- 31.7/50.1 MB 5.0 MB/s eta 0:00:04\n", - " ------------------------- -------------- 32.0/50.1 MB 5.0 MB/s eta 0:00:04\n", - " ------------------------- -------------- 32.1/50.1 MB 4.9 MB/s eta 0:00:04\n", - " ------------------------- -------------- 32.5/50.1 MB 5.0 MB/s eta 0:00:04\n", - " -------------------------- ------------- 32.8/50.1 MB 5.0 MB/s eta 0:00:04\n", - " -------------------------- ------------- 33.0/50.1 MB 5.0 MB/s eta 0:00:04\n", - " -------------------------- ------------- 33.2/50.1 MB 5.0 MB/s eta 0:00:04\n", - " -------------------------- ------------- 33.5/50.1 MB 5.0 MB/s eta 0:00:04\n", - " -------------------------- ------------- 33.8/50.1 MB 5.1 MB/s eta 0:00:04\n", - " --------------------------- ------------ 34.0/50.1 MB 5.2 MB/s eta 0:00:04\n", - " --------------------------- ------------ 34.3/50.1 MB 5.2 MB/s eta 0:00:04\n", - " --------------------------- ------------ 34.4/50.1 MB 5.2 MB/s eta 0:00:04\n", - " --------------------------- ------------ 34.7/50.1 MB 5.1 MB/s eta 0:00:04\n", - " --------------------------- ------------ 34.9/50.1 MB 5.2 MB/s eta 0:00:03\n", - " --------------------------- ------------ 34.9/50.1 MB 5.2 MB/s eta 0:00:03\n", - " --------------------------- ------------ 34.9/50.1 MB 5.2 MB/s eta 0:00:03\n", - " --------------------------- ------------ 34.9/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ---------------------------- ----------- 35.4/50.1 MB 5.0 MB/s eta 0:00:03\n", - " ---------------------------- ----------- 35.7/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ---------------------------- ----------- 36.0/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ---------------------------- ----------- 36.2/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ----------------------------- ---------- 36.5/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ----------------------------- ---------- 36.7/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ----------------------------- ---------- 37.0/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ----------------------------- ---------- 37.2/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ----------------------------- ---------- 37.4/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ------------------------------ --------- 37.7/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ------------------------------ --------- 37.9/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ------------------------------ --------- 38.1/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ------------------------------ --------- 38.3/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ------------------------------ --------- 38.6/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ------------------------------- -------- 39.0/50.1 MB 5.3 MB/s eta 0:00:03\n", - " ------------------------------- -------- 39.1/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ------------------------------- -------- 39.3/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ------------------------------- -------- 39.5/50.1 MB 5.2 MB/s eta 0:00:03\n", - " ------------------------------- -------- 39.8/50.1 MB 5.2 MB/s eta 0:00:02\n", - " ------------------------------- -------- 40.0/50.1 MB 5.2 MB/s eta 0:00:02\n", - " -------------------------------- ------- 40.2/50.1 MB 5.2 MB/s eta 0:00:02\n", - " -------------------------------- ------- 40.4/50.1 MB 5.2 MB/s eta 0:00:02\n", - " -------------------------------- ------- 40.5/50.1 MB 5.1 MB/s eta 0:00:02\n", - " -------------------------------- ------- 40.8/50.1 MB 5.1 MB/s eta 0:00:02\n", - " -------------------------------- ------- 40.9/50.1 MB 5.0 MB/s eta 0:00:02\n", - " -------------------------------- ------- 41.1/50.1 MB 5.0 MB/s eta 0:00:02\n", - " --------------------------------- ------ 41.4/50.1 MB 5.0 MB/s eta 0:00:02\n", - " --------------------------------- ------ 41.6/50.1 MB 5.0 MB/s eta 0:00:02\n", - " --------------------------------- ------ 41.9/50.1 MB 5.1 MB/s eta 0:00:02\n", - " --------------------------------- ------ 42.2/50.1 MB 5.1 MB/s eta 0:00:02\n", - " ---------------------------------- ----- 42.6/50.1 MB 5.2 MB/s eta 0:00:02\n", - " ---------------------------------- ----- 42.8/50.1 MB 5.2 MB/s eta 0:00:02\n", - " ---------------------------------- ----- 43.1/50.1 MB 5.2 MB/s eta 0:00:02\n", - " ---------------------------------- ----- 43.4/50.1 MB 5.1 MB/s eta 0:00:02\n", - " ---------------------------------- ----- 43.8/50.1 MB 5.2 MB/s eta 0:00:02\n", - " ----------------------------------- ---- 43.9/50.1 MB 5.2 MB/s eta 0:00:02\n", - " ----------------------------------- ---- 44.2/50.1 MB 5.1 MB/s eta 0:00:02\n", - " ----------------------------------- ---- 44.5/50.1 MB 5.2 MB/s eta 0:00:02\n", - " ----------------------------------- ---- 44.7/50.1 MB 5.1 MB/s eta 0:00:02\n", - " ----------------------------------- ---- 44.9/50.1 MB 5.2 MB/s eta 0:00:01\n", - " ------------------------------------ --- 45.3/50.1 MB 5.6 MB/s eta 0:00:01\n", - " ------------------------------------ --- 45.4/50.1 MB 5.6 MB/s eta 0:00:01\n", - " ------------------------------------ --- 45.6/50.1 MB 5.4 MB/s eta 0:00:01\n", - " ------------------------------------ --- 45.7/50.1 MB 5.4 MB/s eta 0:00:01\n", - " ------------------------------------ --- 46.0/50.1 MB 5.4 MB/s eta 0:00:01\n", - " ------------------------------------ --- 46.1/50.1 MB 5.3 MB/s eta 0:00:01\n", - " ------------------------------------- -- 46.6/50.1 MB 5.4 MB/s eta 0:00:01\n", - " ------------------------------------- -- 46.9/50.1 MB 5.5 MB/s eta 0:00:01\n", - " ------------------------------------- -- 47.2/50.1 MB 5.5 MB/s eta 0:00:01\n", - " ------------------------------------- -- 47.4/50.1 MB 5.5 MB/s eta 0:00:01\n", - " ------------------------------------- -- 47.5/50.1 MB 5.5 MB/s eta 0:00:01\n", - " -------------------------------------- - 47.8/50.1 MB 5.5 MB/s eta 0:00:01\n", - " -------------------------------------- - 47.9/50.1 MB 5.5 MB/s eta 0:00:01\n", - " -------------------------------------- - 48.0/50.1 MB 5.5 MB/s eta 0:00:01\n", - " -------------------------------------- - 48.2/50.1 MB 5.5 MB/s eta 0:00:01\n", - " -------------------------------------- - 48.4/50.1 MB 5.5 MB/s eta 0:00:01\n", - " -------------------------------------- - 48.7/50.1 MB 5.4 MB/s eta 0:00:01\n", - " -------------------------------------- - 48.8/50.1 MB 5.4 MB/s eta 0:00:01\n", - " --------------------------------------- 48.9/50.1 MB 5.3 MB/s eta 0:00:01\n", - " --------------------------------------- 49.0/50.1 MB 5.2 MB/s eta 0:00:01\n", - " --------------------------------------- 49.2/50.1 MB 5.2 MB/s eta 0:00:01\n", - " --------------------------------------- 49.4/50.1 MB 5.2 MB/s eta 0:00:01\n", - " --------------------------------------- 49.6/50.1 MB 5.2 MB/s eta 0:00:01\n", - " --------------------------------------- 49.8/50.1 MB 5.2 MB/s eta 0:00:01\n", - " --------------------------------------- 50.0/50.1 MB 5.2 MB/s eta 0:00:01\n", - " --------------------------------------- 50.1/50.1 MB 5.2 MB/s eta 0:00:01\n", - " --------------------------------------- 50.1/50.1 MB 5.2 MB/s eta 0:00:01\n", - " --------------------------------------- 50.1/50.1 MB 5.2 MB/s eta 0:00:01\n", - " ---------------------------------------- 50.1/50.1 MB 4.8 MB/s eta 0:00:00\n", - "Downloading PyQt5-5.15.10-cp37-abi3-win_amd64.whl (6.8 MB)\n", - " ---------------------------------------- 0.0/6.8 MB ? eta -:--:--\n", - " - -------------------------------------- 0.2/6.8 MB 6.3 MB/s eta 0:00:02\n", - " -- ------------------------------------- 0.4/6.8 MB 4.6 MB/s eta 0:00:02\n", - " -- ------------------------------------- 0.5/6.8 MB 4.0 MB/s eta 0:00:02\n", - " --- ------------------------------------ 0.6/6.8 MB 4.1 MB/s eta 0:00:02\n", - " ---- ----------------------------------- 0.7/6.8 MB 3.7 MB/s eta 0:00:02\n", - " ---- ----------------------------------- 0.8/6.8 MB 3.3 MB/s eta 0:00:02\n", - " ----- ---------------------------------- 0.9/6.8 MB 3.5 MB/s eta 0:00:02\n", - " ------ --------------------------------- 1.1/6.8 MB 3.3 MB/s eta 0:00:02\n", - " ------- -------------------------------- 1.3/6.8 MB 3.5 MB/s eta 0:00:02\n", - " -------- ------------------------------- 1.5/6.8 MB 3.5 MB/s eta 0:00:02\n", - " --------- ------------------------------ 1.7/6.8 MB 3.7 MB/s eta 0:00:02\n", - " ---------- ----------------------------- 1.8/6.8 MB 3.6 MB/s eta 0:00:02\n", - " ----------- ---------------------------- 2.0/6.8 MB 3.7 MB/s eta 0:00:02\n", - " ------------ --------------------------- 2.2/6.8 MB 3.7 MB/s eta 0:00:02\n", - " -------------- ------------------------- 2.4/6.8 MB 3.8 MB/s eta 0:00:02\n", - " --------------- ------------------------ 2.7/6.8 MB 3.8 MB/s eta 0:00:02\n", - " --------------- ------------------------ 2.7/6.8 MB 3.8 MB/s eta 0:00:02\n", - " ----------------- ---------------------- 3.0/6.8 MB 3.9 MB/s eta 0:00:01\n", - " ------------------ --------------------- 3.1/6.8 MB 3.9 MB/s eta 0:00:01\n", - " ------------------- -------------------- 3.3/6.8 MB 3.9 MB/s eta 0:00:01\n", - " -------------------- ------------------- 3.5/6.8 MB 4.0 MB/s eta 0:00:01\n", - " --------------------- ------------------ 3.7/6.8 MB 4.0 MB/s eta 0:00:01\n", - " ------------------------ --------------- 4.1/6.8 MB 4.2 MB/s eta 0:00:01\n", - " ------------------------ --------------- 4.2/6.8 MB 4.0 MB/s eta 0:00:01\n", - " ------------------------- -------------- 4.4/6.8 MB 4.2 MB/s eta 0:00:01\n", - " --------------------------- ------------ 4.7/6.8 MB 4.2 MB/s eta 0:00:01\n", - " ---------------------------- ----------- 4.9/6.8 MB 4.2 MB/s eta 0:00:01\n", - " ------------------------------ --------- 5.2/6.8 MB 4.3 MB/s eta 0:00:01\n", - " -------------------------------- ------- 5.6/6.8 MB 4.5 MB/s eta 0:00:01\n", - " ---------------------------------- ----- 6.0/6.8 MB 4.6 MB/s eta 0:00:01\n", - " ------------------------------------ --- 6.2/6.8 MB 4.6 MB/s eta 0:00:01\n", - " ------------------------------------- -- 6.5/6.8 MB 4.7 MB/s eta 0:00:01\n", - " --------------------------------------- 6.8/6.8 MB 4.8 MB/s eta 0:00:01\n", - " ---------------------------------------- 6.8/6.8 MB 4.7 MB/s eta 0:00:00\n", - "Downloading PyQt5_sip-12.13.0-cp311-cp311-win_amd64.whl (78 kB)\n", - " ---------------------------------------- 0.0/78.5 kB ? eta -:--:--\n", - " ---------------------------------------- 78.5/78.5 kB ? eta 0:00:00\n", - "Installing collected packages: PyQt5-Qt5, PyQt5-sip, PyQt5\n", - "Successfully installed PyQt5-5.15.10 PyQt5-Qt5-5.15.2 PyQt5-sip-12.13.0\n" - ] - } - ], - "source": [ - "pip install PyQt5" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Usage" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "import gym\n", - "import time\n", - "\n", - "# Create the environment\n", - "env = gym.make(\"CartPole-v1\", render_mode=\"human\")\n", - "\n", - "# Reset the environment and get the initial observation\n", - "observation = env.reset()\n", - "\n", - "for _ in range(1000):\n", - " # Select a random action from the action space\n", - " action = env.action_space.sample()\n", - " # Apply the action to the environment\n", - " # Returns next observation, reward, done signal (indicating\n", - " # if the episode has ended), and an additional info dictionary\n", - " observation, reward, terminated, truncated, info = env.step(action)\n", - " # Render the environment to visualize the agent's behavior\n", - " env.render()\n", - " if terminated: \n", - " # Terminated before max step\n", - " break\n", - " time.sleep(0.2) # Sleep added to slow down the visualization\n", - "\n", - "env.close()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Upload model to Hugging Face hub" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'model' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[8], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mhuggingface_sb3\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m package_to_hub, push_to_hub\n\u001b[1;32m----> 3\u001b[0m package_to_hub(model\u001b[38;5;241m=\u001b[39m\u001b[43mmodel\u001b[49m, \n\u001b[0;32m 4\u001b[0m model_name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124ma2c-CartPole-v1\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 5\u001b[0m model_architecture\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124ma2c\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 6\u001b[0m env_id\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCartPole-v1\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 7\u001b[0m eval_env\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[0;32m 8\u001b[0m repo_id\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124moscarchaufour/a2c-CartPole-v1\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 9\u001b[0m commit_message\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTest commit\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 11\u001b[0m push_to_hub(repo_id\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124moscarchaufour/a2c-CartPole-v1\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 12\u001b[0m filename\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124ma2c_sb3_cartpole.zip\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 13\u001b[0m commit_message\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAdded A2C CartPole model\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", - "\u001b[1;31mNameError\u001b[0m: name 'model' is not defined" - ] - } - ], - "source": [ - "from huggingface_sb3 import package_to_hub, push_to_hub\n", - "\n", - "package_to_hub(model=model, \n", - " model_name=\"a2c-CartPole-v1\",\n", - " model_architecture=\"a2c\",\n", - " env_id=\"CartPole-v1\",\n", - " eval_env=None,\n", - " repo_id=\"oscarchaufour/a2c-CartPole-v1\",\n", - " commit_message=\"Test commit\")\n", - " \n", - "push_to_hub(repo_id=\"oscarchaufour/a2c-CartPole-v1\",\n", - " filename=\"a2c_sb3_cartpole.zip\",\n", - " commit_message=\"Added A2C CartPole model\")\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}