Skip to content
Snippets Groups Projects
Commit f89b6348 authored by oscarchaufour's avatar oscarchaufour
Browse files

updates

parent 6204f77e
No related branches found
No related tags found
No related merge requests found
......@@ -3,3 +3,6 @@
### Get familiar with Hugging Face Hub
Link to the model on the hub :
# REINFORCE
Plot showing the total reward accross episodes: ![Alt text](images/reinforce_rewards.png)
......@@ -2,8 +2,15 @@ import gymnasium as 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
env = gym.make("CartPole-v1", render_mode="rgb_array")
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)
model = A2C("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=10_000)
......@@ -18,15 +25,16 @@ for i in range(1000):
# if done:
# obs = vec_env.reset()
if __name__ == "__main__":
package_to_hub(model=model,
# 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="CartPole-v1",
env_id=env_id,
eval_env=env,
repo_id="oscarchaufour/a2c-CartPole-v1",
commit_message="Test commit")
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="a2c_sb3_cartpole.zip",
filename=model_package_id + ".zip",
commit_message="Added A2C CartPole model")
\ No newline at end of file
images/reinforce_rewards.png

35.7 KiB

File added
......@@ -5,6 +5,7 @@ import torch.optim as optim
import matplotlib.pyplot as plt
from tqdm import tqdm
import numpy as np
from torch.distributions import Categorical
# Define the neural network model
class Policy(nn.Module):
......@@ -24,77 +25,68 @@ class Policy(nn.Module):
x = self.softmax(x)
return x
def reinforce():
# Create the environment
env = gym.make("CartPole-v1")
# Set up the agent
policy = Policy(
input_size=env.observation_space.shape[0],
output_size=env.action_space.n
)
optimizer = optim.Adam(policy.parameters(), lr=5e-3)
def reinforce(policy, env, optimizer):
# Training loop
num_episodes = 500
num_episodes = 200
gamma = 0.99
episode_rewards = []
episodes_rewards = []
for episode in tqdm(range(num_episodes)):
action_probabilities = []
episode_rewards_weighted = []
# Reset the environment and get the initial observation
observation = env.reset()[0]
observation = env.reset()
rewards = []
log_probabilities = []
terminated = False
episode_reward = 0
step = 0
while not terminated:
step += 1
# Compute action probabilities
action_probs = policy(torch.FloatTensor(observation).unsqueeze(0))
observation_array = observation[0] if isinstance(observation, tuple) else observation
observation_tensor = torch.FloatTensor(observation_array).unsqueeze(0)
action_probabilities = policy(observation_tensor)
cat = Categorical(action_probabilities)
# Sample action based on probabilities and store its probability in the buffer
action = torch.multinomial(action_probs, num_samples=1).item()
action = cat.sample()
log_probability = cat.log_prob(action)
# Step the environment with the action
observation, reward, terminated, truncated, info = env.step(action)
observation, reward, terminated, _, _ = env.step(action.item())
env.render()
# Compute and store the return in the buffer
# Compute and store the reward in the buffer
episode_reward += reward
episode_rewards_weighted.append(reward * gamma ** step)
#episode_rewards.append(episode_reward)
log_probabilities.append(log_probability)
rewards.append(reward)
# Store the action probabilities
action_probabilities.append(action_probs[0][action])
episodes_rewards.append(episode_reward)
# Normalize the return
# Convert action_probabilities to a tensor with requires_grad=True
action_probabilities_tensor = torch.FloatTensor(action_probabilities).requires_grad_(True)
episode_rewards_tensor = torch.FloatTensor(episode_rewards_weighted)
episode_rewards_tensor -= torch.mean(episode_rewards_tensor)
episode_rewards_tensor /= torch.std(episode_rewards_tensor)
# Compute the returns
weighted_rewards = 0
returns = []
for r in rewards[::-1]:
weighted_rewards = r + gamma * weighted_rewards
returns.insert(0, weighted_rewards)
returns = torch.tensor(returns)
returns = (returns - returns.mean()) / (returns.std() + 1e-5)
# Compute policy loss
log_probs = torch.log(action_probabilities_tensor.squeeze(0))
policy_loss = -torch.sum(log_probs * torch.tensor(episode_rewards_weighted))
loss = []
for log_prob, weighted_rewards in zip(log_probabilities, returns):
loss.append(log_prob * weighted_rewards)
policy_loss = - torch.cat(loss).sum()
# Update the policy
optimizer.zero_grad()
policy_loss.backward()
optimizer.step()
episode_rewards.append(episode_reward)
return episode_rewards
return episodes_rewards
def plot_rewards(episode_rewards):
def plot_rewards(episodes_rewards):
# Plot the total reward across episodes
plt.plot(episode_rewards)
plt.plot(episodes_rewards)
plt.xlabel('Episode')
plt.ylabel('Total Reward')
plt.title('REINFORCE: Total Reward across Episodes')
......@@ -102,5 +94,33 @@ def plot_rewards(episode_rewards):
if __name__ == "__main__":
episode_rewards = reinforce()
plot_rewards(episode_rewards)
\ No newline at end of file
# Create the environment
env = gym.make("CartPole-v1")
# Set up the agent
policy = Policy(
input_size=env.observation_space.shape[0],
output_size=env.action_space.n
)
optimizer = optim.Adam(policy.parameters(), lr=5e-3)
episodes_rewards = reinforce(policy, env, optimizer)
env.close()
# plot the rewards
plot_rewards(episodes_rewards)
# Serialize the model and save it to a .zip file
# import pickle
# import zipfile
# Assuming `policy` is your neural network model
# # Step 1: Serialize the model
# model_bytes = pickle.dumps(policy)
# # Step 2: Create a .zip file containing the serialized model
# zip_filename = ".zip"
# with zipfile.ZipFile(zip_filename, 'w') as zipf:
# zipf.writestr("model.pkl", model_bytes)
%% Cell type:markdown id: tags:
# TD 1 : Hands-On Reinforcement Learning
%% Cell type:markdown id: tags:
## Packages download
%% Cell type:code id: tags:
``` python
pip install pytorch
```
%% Output
Collecting pytorch
Downloading pytorch-1.0.2.tar.gz (689 bytes)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: pytorch
Building wheel for pytorch (pyproject.toml): started
Building wheel for pytorch (pyproject.toml): finished with status 'error'
Failed to build pytorch
Note: you may need to restart the kernel to use updated packages.
error: subprocess-exited-with-error
× Building wheel for pytorch (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
Traceback (most recent call last):
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>
main()
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
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
return _build_backend().build_wheel(wheel_directory, config_settings,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\oscar\AppData\Local\Temp\pip-build-env-onf33rce\overlay\Lib\site-packages\setuptools\build_meta.py", line 404, in build_wheel
return self._build_with_temp_dir(
^^^^^^^^^^^^^^^^^^^^^^^^^^
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
self.run_setup()
File "C:\Users\oscar\AppData\Local\Temp\pip-build-env-onf33rce\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup
super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
File "C:\Users\oscar\AppData\Local\Temp\pip-build-env-onf33rce\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 15, in <module>
Exception: You tried to install "pytorch". The package named for PyTorch is "torch"
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pytorch
ERROR: Could not build wheels for pytorch, which is required to install pyproject.toml-based projects
%% Cell type:code id: tags:
``` python
pip install gym==0.26.2
```
%% Output
Collecting gym==0.26.2Note: you may need to restart the kernel to use updated packages.
Downloading gym-0.26.2.tar.gz (721 kB)
---------------------------------------- 0.0/721.7 kB ? eta -:--:--
---- ---------------------------------- 92.2/721.7 kB 2.6 MB/s eta 0:00:01
------------ ------------------------- 235.5/721.7 kB 3.6 MB/s eta 0:00:01
------------------ ------------------- 358.4/721.7 kB 2.8 MB/s eta 0:00:01
------------------------- ------------ 481.3/721.7 kB 2.7 MB/s eta 0:00:01
-------------------------------- ----- 624.6/721.7 kB 2.8 MB/s eta 0:00:01
-------------------------------------- 721.7/721.7 kB 2.7 MB/s eta 0:00:00
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting numpy>=1.18.0 (from gym==0.26.2)
Downloading numpy-1.26.4-cp311-cp311-win_amd64.whl.metadata (61 kB)
---------------------------------------- 0.0/61.0 kB ? eta -:--:--
--------------------------------- ------ 51.2/61.0 kB 1.3 MB/s eta 0:00:01
---------------------------------------- 61.0/61.0 kB 1.1 MB/s eta 0:00:00
Collecting cloudpickle>=1.2.0 (from gym==0.26.2)
Downloading cloudpickle-3.0.0-py3-none-any.whl.metadata (7.0 kB)
Collecting gym-notices>=0.0.4 (from gym==0.26.2)
Downloading gym_notices-0.0.8-py3-none-any.whl (3.0 kB)
Downloading cloudpickle-3.0.0-py3-none-any.whl (20 kB)
Downloading numpy-1.26.4-cp311-cp311-win_amd64.whl (15.8 MB)
---------------------------------------- 0.0/15.8 MB ? eta -:--:--
---------------------------------------- 0.2/15.8 MB 5.9 MB/s eta 0:00:03
--------------------------------------- 0.3/15.8 MB 4.1 MB/s eta 0:00:04
- -------------------------------------- 0.4/15.8 MB 3.1 MB/s eta 0:00:05
- -------------------------------------- 0.5/15.8 MB 3.3 MB/s eta 0:00:05
- -------------------------------------- 0.5/15.8 MB 2.8 MB/s eta 0:00:06
- -------------------------------------- 0.7/15.8 MB 2.9 MB/s eta 0:00:06
- -------------------------------------- 0.7/15.8 MB 2.9 MB/s eta 0:00:06
-- ------------------------------------- 0.8/15.8 MB 2.5 MB/s eta 0:00:06
-- ------------------------------------- 0.9/15.8 MB 2.4 MB/s eta 0:00:07
-- ------------------------------------- 1.0/15.8 MB 2.2 MB/s eta 0:00:07
-- ------------------------------------- 1.0/15.8 MB 2.1 MB/s eta 0:00:08
-- ------------------------------------- 1.1/15.8 MB 2.1 MB/s eta 0:00:07
--- ------------------------------------ 1.2/15.8 MB 2.2 MB/s eta 0:00:07
--- ------------------------------------ 1.3/15.8 MB 2.2 MB/s eta 0:00:07
--- ------------------------------------ 1.5/15.8 MB 2.2 MB/s eta 0:00:07
--- ------------------------------------ 1.5/15.8 MB 2.1 MB/s eta 0:00:07
---- ----------------------------------- 1.6/15.8 MB 2.2 MB/s eta 0:00:07
---- ----------------------------------- 1.7/15.8 MB 2.1 MB/s eta 0:00:07
---- ----------------------------------- 1.8/15.8 MB 2.2 MB/s eta 0:00:07
----- ---------------------------------- 2.0/15.8 MB 2.3 MB/s eta 0:00:06
----- ---------------------------------- 2.2/15.8 MB 2.4 MB/s eta 0:00:06
----- ---------------------------------- 2.3/15.8 MB 2.4 MB/s eta 0:00:06
------ --------------------------------- 2.4/15.8 MB 2.4 MB/s eta 0:00:06
------ --------------------------------- 2.5/15.8 MB 2.4 MB/s eta 0:00:06
------ --------------------------------- 2.6/15.8 MB 2.4 MB/s eta 0:00:06
------ --------------------------------- 2.7/15.8 MB 2.3 MB/s eta 0:00:06
------- -------------------------------- 2.9/15.8 MB 2.4 MB/s eta 0:00:06
------- -------------------------------- 2.9/15.8 MB 2.3 MB/s eta 0:00:06
------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06
------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06
------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06
------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06
------- -------------------------------- 3.1/15.8 MB 2.4 MB/s eta 0:00:06
-------- ------------------------------- 3.3/15.8 MB 2.2 MB/s eta 0:00:06
-------- ------------------------------- 3.4/15.8 MB 2.2 MB/s eta 0:00:06
-------- ------------------------------- 3.5/15.8 MB 2.2 MB/s eta 0:00:06
--------- ------------------------------ 3.6/15.8 MB 2.2 MB/s eta 0:00:06
--------- ------------------------------ 3.6/15.8 MB 2.2 MB/s eta 0:00:06
--------- ------------------------------ 3.7/15.8 MB 2.2 MB/s eta 0:00:06
--------- ------------------------------ 3.7/15.8 MB 2.1 MB/s eta 0:00:06
--------- ------------------------------ 3.9/15.8 MB 2.1 MB/s eta 0:00:06
---------- ----------------------------- 4.0/15.8 MB 2.2 MB/s eta 0:00:06
---------- ----------------------------- 4.1/15.8 MB 2.2 MB/s eta 0:00:06
---------- ----------------------------- 4.1/15.8 MB 2.2 MB/s eta 0:00:06
---------- ----------------------------- 4.3/15.8 MB 2.2 MB/s eta 0:00:06
----------- ---------------------------- 4.4/15.8 MB 2.2 MB/s eta 0:00:06
----------- ---------------------------- 4.6/15.8 MB 2.2 MB/s eta 0:00:06
----------- ---------------------------- 4.7/15.8 MB 2.3 MB/s eta 0:00:05
------------ --------------------------- 4.8/15.8 MB 2.3 MB/s eta 0:00:05
------------ --------------------------- 5.0/15.8 MB 2.3 MB/s eta 0:00:05
------------ --------------------------- 5.1/15.8 MB 2.3 MB/s eta 0:00:05
------------- -------------------------- 5.3/15.8 MB 2.3 MB/s eta 0:00:05
------------- -------------------------- 5.4/15.8 MB 2.4 MB/s eta 0:00:05
------------- -------------------------- 5.4/15.8 MB 2.3 MB/s eta 0:00:05
------------- -------------------------- 5.5/15.8 MB 2.3 MB/s eta 0:00:05
-------------- ------------------------- 5.6/15.8 MB 2.3 MB/s eta 0:00:05
-------------- ------------------------- 5.8/15.8 MB 2.3 MB/s eta 0:00:05
-------------- ------------------------- 5.9/15.8 MB 2.3 MB/s eta 0:00:05
--------------- ------------------------ 6.0/15.8 MB 2.3 MB/s eta 0:00:05
--------------- ------------------------ 6.1/15.8 MB 2.3 MB/s eta 0:00:05
--------------- ------------------------ 6.2/15.8 MB 2.3 MB/s eta 0:00:05
---------------- ----------------------- 6.4/15.8 MB 2.4 MB/s eta 0:00:05
---------------- ----------------------- 6.4/15.8 MB 2.3 MB/s eta 0:00:05
---------------- ----------------------- 6.6/15.8 MB 2.3 MB/s eta 0:00:04
----------------- ---------------------- 6.7/15.8 MB 2.4 MB/s eta 0:00:04
----------------- ---------------------- 7.0/15.8 MB 2.4 MB/s eta 0:00:04
----------------- ---------------------- 7.1/15.8 MB 2.4 MB/s eta 0:00:04
------------------ --------------------- 7.3/15.8 MB 2.4 MB/s eta 0:00:04
------------------ --------------------- 7.5/15.8 MB 2.5 MB/s eta 0:00:04
------------------- -------------------- 7.5/15.8 MB 2.4 MB/s eta 0:00:04
------------------- -------------------- 7.7/15.8 MB 2.5 MB/s eta 0:00:04
------------------- -------------------- 7.7/15.8 MB 2.5 MB/s eta 0:00:04
------------------- -------------------- 7.9/15.8 MB 2.4 MB/s eta 0:00:04
-------------------- ------------------- 8.0/15.8 MB 2.5 MB/s eta 0:00:04
-------------------- ------------------- 8.2/15.8 MB 2.5 MB/s eta 0:00:04
--------------------- ------------------ 8.4/15.8 MB 2.5 MB/s eta 0:00:03
--------------------- ------------------ 8.5/15.8 MB 2.5 MB/s eta 0:00:03
--------------------- ------------------ 8.7/15.8 MB 2.6 MB/s eta 0:00:03
---------------------- ----------------- 8.8/15.8 MB 2.6 MB/s eta 0:00:03
----------------------- ---------------- 9.1/15.8 MB 2.6 MB/s eta 0:00:03
----------------------- ---------------- 9.2/15.8 MB 2.6 MB/s eta 0:00:03
----------------------- ---------------- 9.3/15.8 MB 2.6 MB/s eta 0:00:03
----------------------- ---------------- 9.3/15.8 MB 2.6 MB/s eta 0:00:03
------------------------ --------------- 9.6/15.8 MB 2.6 MB/s eta 0:00:03
------------------------ --------------- 9.7/15.8 MB 2.6 MB/s eta 0:00:03
------------------------ --------------- 9.9/15.8 MB 2.6 MB/s eta 0:00:03
------------------------- -------------- 10.0/15.8 MB 2.6 MB/s eta 0:00:03
------------------------- -------------- 10.1/15.8 MB 2.6 MB/s eta 0:00:03
------------------------- -------------- 10.2/15.8 MB 2.6 MB/s eta 0:00:03
-------------------------- ------------- 10.3/15.8 MB 2.6 MB/s eta 0:00:03
-------------------------- ------------- 10.5/15.8 MB 2.6 MB/s eta 0:00:03
-------------------------- ------------- 10.7/15.8 MB 2.6 MB/s eta 0:00:02
--------------------------- ------------ 10.8/15.8 MB 2.7 MB/s eta 0:00:02
---------------------------- ----------- 11.1/15.8 MB 2.7 MB/s eta 0:00:02
---------------------------- ----------- 11.3/15.8 MB 2.8 MB/s eta 0:00:02
---------------------------- ----------- 11.4/15.8 MB 2.8 MB/s eta 0:00:02
----------------------------- ---------- 11.6/15.8 MB 2.8 MB/s eta 0:00:02
------------------------------ --------- 11.9/15.8 MB 2.9 MB/s eta 0:00:02
------------------------------ --------- 12.1/15.8 MB 2.9 MB/s eta 0:00:02
------------------------------- -------- 12.3/15.8 MB 2.9 MB/s eta 0:00:02
------------------------------- -------- 12.5/15.8 MB 3.0 MB/s eta 0:00:02
-------------------------------- ------- 12.7/15.8 MB 3.0 MB/s eta 0:00:02
-------------------------------- ------- 12.9/15.8 MB 3.1 MB/s eta 0:00:01
--------------------------------- ------ 13.1/15.8 MB 3.1 MB/s eta 0:00:01
--------------------------------- ------ 13.4/15.8 MB 3.3 MB/s eta 0:00:01
---------------------------------- ----- 13.6/15.8 MB 3.3 MB/s eta 0:00:01
---------------------------------- ----- 13.7/15.8 MB 3.4 MB/s eta 0:00:01
---------------------------------- ----- 13.8/15.8 MB 3.3 MB/s eta 0:00:01
----------------------------------- ---- 14.0/15.8 MB 3.4 MB/s eta 0:00:01
----------------------------------- ---- 14.1/15.8 MB 3.4 MB/s eta 0:00:01
------------------------------------ --- 14.3/15.8 MB 3.5 MB/s eta 0:00:01
------------------------------------ --- 14.5/15.8 MB 3.5 MB/s eta 0:00:01
------------------------------------- -- 14.6/15.8 MB 3.5 MB/s eta 0:00:01
------------------------------------- -- 14.9/15.8 MB 3.5 MB/s eta 0:00:01
------------------------------------- -- 15.0/15.8 MB 3.5 MB/s eta 0:00:01
-------------------------------------- - 15.2/15.8 MB 3.6 MB/s eta 0:00:01
--------------------------------------- 15.4/15.8 MB 3.6 MB/s eta 0:00:01
--------------------------------------- 15.6/15.8 MB 3.6 MB/s eta 0:00:01
--------------------------------------- 15.8/15.8 MB 3.7 MB/s eta 0:00:01
---------------------------------------- 15.8/15.8 MB 3.7 MB/s eta 0:00:00
Building wheels for collected packages: gym
Building wheel for gym (pyproject.toml): started
Building wheel for gym (pyproject.toml): finished with status 'done'
Created wheel for gym: filename=gym-0.26.2-py3-none-any.whl size=827629 sha256=73a686c8633b88e54b0477d643a4d44b9c28378813129811ee402183300c3525
Stored in directory: c:\users\oscar\appdata\local\pip\cache\wheels\1c\77\9e\9af5470201a0b0543937933ee99ba884cd237d2faefe8f4d37
Successfully built gym
Installing collected packages: gym-notices, numpy, cloudpickle, gym
Successfully installed cloudpickle-3.0.0 gym-0.26.2 gym-notices-0.0.8 numpy-1.26.4
%% Cell type:code id: tags:
``` python
pip install pyglet==2.0.10
```
%% Output
Collecting pyglet==2.0.10
Downloading pyglet-2.0.10-py3-none-any.whl.metadata (8.5 kB)
Downloading pyglet-2.0.10-py3-none-any.whl (858 kB)
---------------------------------------- 0.0/858.3 kB ? eta -:--:--
---------------------------------------- 0.0/858.3 kB ? eta -:--:--
---------------------------------------- 0.0/858.3 kB ? eta -:--:--
- -------------------------------------- 30.7/858.3 kB ? eta -:--:--
- -------------------------------------- 30.7/858.3 kB ? eta -:--:--
- ------------------------------------- 41.0/858.3 kB 330.3 kB/s eta 0:00:03
---- --------------------------------- 112.6/858.3 kB 595.3 kB/s eta 0:00:02
---- --------------------------------- 112.6/858.3 kB 595.3 kB/s eta 0:00:02
---- --------------------------------- 112.6/858.3 kB 595.3 kB/s eta 0:00:02
----- -------------------------------- 122.9/858.3 kB 379.3 kB/s eta 0:00:02
----- -------------------------------- 122.9/858.3 kB 379.3 kB/s eta 0:00:02
------ ------------------------------- 143.4/858.3 kB 341.3 kB/s eta 0:00:03
-------- ----------------------------- 194.6/858.3 kB 472.6 kB/s eta 0:00:02
-------- ----------------------------- 194.6/858.3 kB 472.6 kB/s eta 0:00:02
-------- ----------------------------- 194.6/858.3 kB 472.6 kB/s eta 0:00:02
----------- -------------------------- 256.0/858.3 kB 477.2 kB/s eta 0:00:02
----------- -------------------------- 256.0/858.3 kB 477.2 kB/s eta 0:00:02
-------------- ----------------------- 327.7/858.3 kB 507.9 kB/s eta 0:00:02
--------------- ---------------------- 358.4/858.3 kB 495.2 kB/s eta 0:00:02
----------------- -------------------- 389.1/858.3 kB 527.7 kB/s eta 0:00:01
------------------- ------------------ 450.6/858.3 kB 563.8 kB/s eta 0:00:01
-------------------- ----------------- 460.8/858.3 kB 544.2 kB/s eta 0:00:01
----------------------- -------------- 532.5/858.3 kB 596.8 kB/s eta 0:00:01
--------------------------- ---------- 614.4/858.3 kB 655.3 kB/s eta 0:00:01
---------------------------- --------- 645.1/858.3 kB 677.6 kB/s eta 0:00:01
------------------------------ ------- 686.1/858.3 kB 675.8 kB/s eta 0:00:01
--------------------------------- ---- 747.5/858.3 kB 704.2 kB/s eta 0:00:01
----------------------------------- -- 798.7/858.3 kB 742.4 kB/s eta 0:00:01
-------------------------------------- 858.3/858.3 kB 753.8 kB/s eta 0:00:00
Installing collected packages: pyglet
Successfully installed pyglet-2.0.10
Note: you may need to restart the kernel to use updated packages.
%% Cell type:code id: tags:
``` python
pip install pygame==2.5.2
```
%% Output
Collecting pygame==2.5.2
Downloading pygame-2.5.2-cp311-cp311-win_amd64.whl.metadata (13 kB)
Downloading pygame-2.5.2-cp311-cp311-win_amd64.whl (10.8 MB)
---------------------------------------- 0.0/10.8 MB ? eta -:--:--
---------------------------------------- 0.1/10.8 MB 3.5 MB/s eta 0:00:04
--------------------------------------- 0.2/10.8 MB 3.7 MB/s eta 0:00:03
- -------------------------------------- 0.4/10.8 MB 3.9 MB/s eta 0:00:03
-- ------------------------------------- 0.7/10.8 MB 4.6 MB/s eta 0:00:03
--- ------------------------------------ 0.9/10.8 MB 4.6 MB/s eta 0:00:03
---- ----------------------------------- 1.1/10.8 MB 5.1 MB/s eta 0:00:02
---- ----------------------------------- 1.3/10.8 MB 5.2 MB/s eta 0:00:02
----- ---------------------------------- 1.5/10.8 MB 5.0 MB/s eta 0:00:02
------ --------------------------------- 1.8/10.8 MB 5.1 MB/s eta 0:00:02
------- -------------------------------- 2.0/10.8 MB 5.2 MB/s eta 0:00:02
-------- ------------------------------- 2.3/10.8 MB 5.4 MB/s eta 0:00:02
--------- ------------------------------ 2.5/10.8 MB 5.2 MB/s eta 0:00:02
---------- ----------------------------- 2.8/10.8 MB 5.4 MB/s eta 0:00:02
----------- ---------------------------- 3.1/10.8 MB 5.7 MB/s eta 0:00:02
----------- ---------------------------- 3.2/10.8 MB 5.6 MB/s eta 0:00:02
------------ --------------------------- 3.4/10.8 MB 5.5 MB/s eta 0:00:02
------------- -------------------------- 3.6/10.8 MB 5.2 MB/s eta 0:00:02
-------------- ------------------------- 3.9/10.8 MB 5.3 MB/s eta 0:00:02
--------------- ------------------------ 4.1/10.8 MB 5.2 MB/s eta 0:00:02
---------------- ----------------------- 4.4/10.8 MB 5.3 MB/s eta 0:00:02
----------------- ---------------------- 4.8/10.8 MB 5.5 MB/s eta 0:00:02
------------------ --------------------- 5.1/10.8 MB 5.6 MB/s eta 0:00:02
------------------- -------------------- 5.3/10.8 MB 5.6 MB/s eta 0:00:01
-------------------- ------------------- 5.6/10.8 MB 5.6 MB/s eta 0:00:01
--------------------- ------------------ 5.8/10.8 MB 5.6 MB/s eta 0:00:01
---------------------- ----------------- 6.0/10.8 MB 5.6 MB/s eta 0:00:01
----------------------- ---------------- 6.3/10.8 MB 5.6 MB/s eta 0:00:01
------------------------ --------------- 6.7/10.8 MB 5.7 MB/s eta 0:00:01
------------------------- -------------- 6.9/10.8 MB 5.8 MB/s eta 0:00:01
-------------------------- ------------- 7.2/10.8 MB 5.8 MB/s eta 0:00:01
--------------------------- ------------ 7.3/10.8 MB 5.6 MB/s eta 0:00:01
---------------------------- ----------- 7.5/10.8 MB 5.7 MB/s eta 0:00:01
----------------------------- ---------- 7.8/10.8 MB 5.7 MB/s eta 0:00:01
----------------------------- ---------- 8.0/10.8 MB 5.6 MB/s eta 0:00:01
------------------------------ --------- 8.2/10.8 MB 5.6 MB/s eta 0:00:01
------------------------------- -------- 8.3/10.8 MB 5.6 MB/s eta 0:00:01
------------------------------- -------- 8.5/10.8 MB 5.5 MB/s eta 0:00:01
-------------------------------- ------- 8.6/10.8 MB 5.3 MB/s eta 0:00:01
-------------------------------- ------- 8.8/10.8 MB 5.4 MB/s eta 0:00:01
--------------------------------- ------ 9.0/10.8 MB 5.4 MB/s eta 0:00:01
---------------------------------- ----- 9.3/10.8 MB 5.4 MB/s eta 0:00:01
------------------------------------ --- 9.8/10.8 MB 5.5 MB/s eta 0:00:01
------------------------------------- -- 10.1/10.8 MB 5.5 MB/s eta 0:00:01
-------------------------------------- - 10.3/10.8 MB 5.5 MB/s eta 0:00:01
--------------------------------------- 10.5/10.8 MB 5.6 MB/s eta 0:00:01
--------------------------------------- 10.7/10.8 MB 5.7 MB/s eta 0:00:01
---------------------------------------- 10.8/10.8 MB 5.5 MB/s eta 0:00:00
Installing collected packages: pygame
Successfully installed pygame-2.5.2
Note: you may need to restart the kernel to use updated packages.
%% Cell type:code id: tags:
``` python
pip install PyQt5
```
%% Output
Collecting PyQt5Note: you may need to restart the kernel to use updated packages.
Downloading PyQt5-5.15.10-cp37-abi3-win_amd64.whl.metadata (2.2 kB)
Collecting PyQt5-sip<13,>=12.13 (from PyQt5)
Downloading PyQt5_sip-12.13.0-cp311-cp311-win_amd64.whl.metadata (524 bytes)
Collecting PyQt5-Qt5>=5.15.2 (from PyQt5)
Downloading PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB)
---------------------------------------- 0.0/50.1 MB ? eta -:--:--
---------------------------------------- 0.1/50.1 MB 4.3 MB/s eta 0:00:12
---------------------------------------- 0.4/50.1 MB 6.1 MB/s eta 0:00:09
--------------------------------------- 0.7/50.1 MB 5.9 MB/s eta 0:00:09
--------------------------------------- 0.9/50.1 MB 5.5 MB/s eta 0:00:09
--------------------------------------- 1.1/50.1 MB 5.7 MB/s eta 0:00:09
- -------------------------------------- 1.4/50.1 MB 5.9 MB/s eta 0:00:09
- -------------------------------------- 1.6/50.1 MB 6.1 MB/s eta 0:00:08
- -------------------------------------- 2.2/50.1 MB 6.6 MB/s eta 0:00:08
- -------------------------------------- 2.5/50.1 MB 6.5 MB/s eta 0:00:08
-- ------------------------------------- 2.8/50.1 MB 6.6 MB/s eta 0:00:08
-- ------------------------------------- 3.1/50.1 MB 6.8 MB/s eta 0:00:07
-- ------------------------------------- 3.2/50.1 MB 6.4 MB/s eta 0:00:08
-- ------------------------------------- 3.4/50.1 MB 6.3 MB/s eta 0:00:08
--- ------------------------------------ 3.8/50.1 MB 6.5 MB/s eta 0:00:08
--- ------------------------------------ 4.1/50.1 MB 6.6 MB/s eta 0:00:08
--- ------------------------------------ 4.5/50.1 MB 6.9 MB/s eta 0:00:07
--- ------------------------------------ 4.8/50.1 MB 6.8 MB/s eta 0:00:07
---- ----------------------------------- 5.1/50.1 MB 6.9 MB/s eta 0:00:07
---- ----------------------------------- 5.4/50.1 MB 6.9 MB/s eta 0:00:07
---- ----------------------------------- 5.6/50.1 MB 6.8 MB/s eta 0:00:07
---- ----------------------------------- 5.9/50.1 MB 6.7 MB/s eta 0:00:07
---- ----------------------------------- 6.2/50.1 MB 6.7 MB/s eta 0:00:07
----- ---------------------------------- 6.6/50.1 MB 6.8 MB/s eta 0:00:07
----- ---------------------------------- 6.9/50.1 MB 6.8 MB/s eta 0:00:07
----- ---------------------------------- 7.3/50.1 MB 6.8 MB/s eta 0:00:07
----- ---------------------------------- 7.4/50.1 MB 6.7 MB/s eta 0:00:07
------ --------------------------------- 7.6/50.1 MB 6.6 MB/s eta 0:00:07
------ --------------------------------- 7.9/50.1 MB 6.8 MB/s eta 0:00:07
------ --------------------------------- 8.3/50.1 MB 6.8 MB/s eta 0:00:07
------ --------------------------------- 8.7/50.1 MB 6.9 MB/s eta 0:00:06
------- -------------------------------- 9.1/50.1 MB 6.8 MB/s eta 0:00:06
------- -------------------------------- 9.5/50.1 MB 6.9 MB/s eta 0:00:06
------- -------------------------------- 9.7/50.1 MB 6.9 MB/s eta 0:00:06
------- -------------------------------- 10.0/50.1 MB 6.9 MB/s eta 0:00:06
-------- ------------------------------- 10.2/50.1 MB 6.8 MB/s eta 0:00:06
-------- ------------------------------- 10.4/50.1 MB 6.7 MB/s eta 0:00:06
-------- ------------------------------- 10.7/50.1 MB 6.9 MB/s eta 0:00:06
-------- ------------------------------- 10.8/50.1 MB 6.7 MB/s eta 0:00:06
-------- ------------------------------- 11.1/50.1 MB 6.8 MB/s eta 0:00:06
--------- ------------------------------ 11.4/50.1 MB 6.8 MB/s eta 0:00:06
--------- ------------------------------ 11.5/50.1 MB 6.7 MB/s eta 0:00:06
--------- ------------------------------ 11.8/50.1 MB 6.7 MB/s eta 0:00:06
--------- ------------------------------ 12.0/50.1 MB 6.6 MB/s eta 0:00:06
--------- ------------------------------ 12.3/50.1 MB 6.6 MB/s eta 0:00:06
--------- ------------------------------ 12.5/50.1 MB 6.4 MB/s eta 0:00:06
---------- ----------------------------- 12.7/50.1 MB 6.4 MB/s eta 0:00:06
---------- ----------------------------- 13.0/50.1 MB 6.4 MB/s eta 0:00:06
---------- ----------------------------- 13.1/50.1 MB 6.3 MB/s eta 0:00:06
---------- ----------------------------- 13.3/50.1 MB 6.3 MB/s eta 0:00:06
---------- ----------------------------- 13.4/50.1 MB 6.2 MB/s eta 0:00:06
---------- ----------------------------- 13.5/50.1 MB 6.1 MB/s eta 0:00:07
---------- ----------------------------- 13.6/50.1 MB 6.2 MB/s eta 0:00:06
----------- ---------------------------- 13.8/50.1 MB 6.0 MB/s eta 0:00:07
----------- ---------------------------- 14.0/50.1 MB 5.9 MB/s eta 0:00:07
----------- ---------------------------- 14.2/50.1 MB 5.8 MB/s eta 0:00:07
----------- ---------------------------- 14.4/50.1 MB 5.8 MB/s eta 0:00:07
----------- ---------------------------- 14.8/50.1 MB 5.7 MB/s eta 0:00:07
----------- ---------------------------- 15.0/50.1 MB 5.7 MB/s eta 0:00:07
------------ --------------------------- 15.1/50.1 MB 5.7 MB/s eta 0:00:07
------------ --------------------------- 15.2/50.1 MB 5.6 MB/s eta 0:00:07
------------ --------------------------- 15.4/50.1 MB 5.5 MB/s eta 0:00:07
------------ --------------------------- 15.6/50.1 MB 5.5 MB/s eta 0:00:07
------------ --------------------------- 15.7/50.1 MB 5.5 MB/s eta 0:00:07
------------ --------------------------- 15.9/50.1 MB 5.5 MB/s eta 0:00:07
------------ --------------------------- 16.1/50.1 MB 5.4 MB/s eta 0:00:07
------------ --------------------------- 16.2/50.1 MB 5.3 MB/s eta 0:00:07
------------- -------------------------- 16.4/50.1 MB 5.3 MB/s eta 0:00:07
------------- -------------------------- 16.7/50.1 MB 5.2 MB/s eta 0:00:07
------------- -------------------------- 16.8/50.1 MB 5.2 MB/s eta 0:00:07
------------- -------------------------- 17.0/50.1 MB 5.2 MB/s eta 0:00:07
------------- -------------------------- 17.2/50.1 MB 5.1 MB/s eta 0:00:07
------------- -------------------------- 17.4/50.1 MB 5.0 MB/s eta 0:00:07
-------------- ------------------------- 17.6/50.1 MB 5.1 MB/s eta 0:00:07
-------------- ------------------------- 17.8/50.1 MB 5.1 MB/s eta 0:00:07
-------------- ------------------------- 18.1/50.1 MB 5.0 MB/s eta 0:00:07
-------------- ------------------------- 18.3/50.1 MB 5.0 MB/s eta 0:00:07
-------------- ------------------------- 18.5/50.1 MB 4.9 MB/s eta 0:00:07
-------------- ------------------------- 18.5/50.1 MB 4.9 MB/s eta 0:00:07
-------------- ------------------------- 18.7/50.1 MB 4.8 MB/s eta 0:00:07
-------------- ------------------------- 18.8/50.1 MB 4.7 MB/s eta 0:00:07
--------------- ------------------------ 18.8/50.1 MB 4.7 MB/s eta 0:00:07
--------------- ------------------------ 19.0/50.1 MB 4.6 MB/s eta 0:00:07
--------------- ------------------------ 19.3/50.1 MB 4.6 MB/s eta 0:00:07
--------------- ------------------------ 19.4/50.1 MB 4.6 MB/s eta 0:00:07
--------------- ------------------------ 19.7/50.1 MB 4.5 MB/s eta 0:00:07
---------------- ----------------------- 20.1/50.1 MB 4.6 MB/s eta 0:00:07
---------------- ----------------------- 20.4/50.1 MB 4.6 MB/s eta 0:00:07
---------------- ----------------------- 20.6/50.1 MB 4.6 MB/s eta 0:00:07
---------------- ----------------------- 20.7/50.1 MB 4.6 MB/s eta 0:00:07
---------------- ----------------------- 21.1/50.1 MB 4.6 MB/s eta 0:00:07
----------------- ---------------------- 21.3/50.1 MB 4.6 MB/s eta 0:00:07
----------------- ---------------------- 21.6/50.1 MB 4.6 MB/s eta 0:00:07
----------------- ---------------------- 21.9/50.1 MB 4.7 MB/s eta 0:00:07
----------------- ---------------------- 22.1/50.1 MB 4.6 MB/s eta 0:00:07
----------------- ---------------------- 22.4/50.1 MB 4.7 MB/s eta 0:00:06
------------------ --------------------- 22.7/50.1 MB 4.7 MB/s eta 0:00:06
------------------ --------------------- 22.9/50.1 MB 4.7 MB/s eta 0:00:06
------------------ --------------------- 23.1/50.1 MB 4.6 MB/s eta 0:00:06
------------------ --------------------- 23.5/50.1 MB 4.7 MB/s eta 0:00:06
------------------ --------------------- 23.6/50.1 MB 4.8 MB/s eta 0:00:06
------------------ --------------------- 23.7/50.1 MB 4.8 MB/s eta 0:00:06
------------------- -------------------- 23.9/50.1 MB 4.8 MB/s eta 0:00:06
------------------- -------------------- 24.3/50.1 MB 4.9 MB/s eta 0:00:06
------------------- -------------------- 24.5/50.1 MB 4.9 MB/s eta 0:00:06
------------------- -------------------- 24.7/50.1 MB 4.9 MB/s eta 0:00:06
------------------- -------------------- 24.9/50.1 MB 4.8 MB/s eta 0:00:06
------------------- -------------------- 25.0/50.1 MB 4.7 MB/s eta 0:00:06
-------------------- ------------------- 25.1/50.1 MB 4.7 MB/s eta 0:00:06
-------------------- ------------------- 25.2/50.1 MB 4.7 MB/s eta 0:00:06
-------------------- ------------------- 25.4/50.1 MB 4.6 MB/s eta 0:00:06
-------------------- ------------------- 25.6/50.1 MB 4.7 MB/s eta 0:00:06
-------------------- ------------------- 25.7/50.1 MB 4.7 MB/s eta 0:00:06
-------------------- ------------------- 26.1/50.1 MB 4.8 MB/s eta 0:00:06
--------------------- ------------------ 26.3/50.1 MB 4.9 MB/s eta 0:00:05
--------------------- ------------------ 26.4/50.1 MB 4.8 MB/s eta 0:00:05
--------------------- ------------------ 26.7/50.1 MB 4.9 MB/s eta 0:00:05
--------------------- ------------------ 26.8/50.1 MB 4.9 MB/s eta 0:00:05
--------------------- ------------------ 27.0/50.1 MB 4.8 MB/s eta 0:00:05
--------------------- ------------------ 27.1/50.1 MB 4.9 MB/s eta 0:00:05
--------------------- ------------------ 27.4/50.1 MB 4.9 MB/s eta 0:00:05
---------------------- ----------------- 27.7/50.1 MB 4.8 MB/s eta 0:00:05
---------------------- ----------------- 27.9/50.1 MB 4.8 MB/s eta 0:00:05
---------------------- ----------------- 28.2/50.1 MB 4.8 MB/s eta 0:00:05
---------------------- ----------------- 28.3/50.1 MB 4.8 MB/s eta 0:00:05
---------------------- ----------------- 28.6/50.1 MB 4.9 MB/s eta 0:00:05
----------------------- ---------------- 28.8/50.1 MB 5.0 MB/s eta 0:00:05
----------------------- ---------------- 29.0/50.1 MB 5.0 MB/s eta 0:00:05
----------------------- ---------------- 29.3/50.1 MB 5.1 MB/s eta 0:00:05
----------------------- ---------------- 29.6/50.1 MB 5.2 MB/s eta 0:00:04
----------------------- ---------------- 29.7/50.1 MB 5.1 MB/s eta 0:00:04
----------------------- ---------------- 29.9/50.1 MB 5.1 MB/s eta 0:00:04
------------------------ --------------- 30.2/50.1 MB 5.1 MB/s eta 0:00:04
------------------------ --------------- 30.4/50.1 MB 5.0 MB/s eta 0:00:04
------------------------ --------------- 30.7/50.1 MB 5.1 MB/s eta 0:00:04
------------------------ --------------- 31.0/50.1 MB 5.1 MB/s eta 0:00:04
------------------------ --------------- 31.2/50.1 MB 5.1 MB/s eta 0:00:04
------------------------- -------------- 31.5/50.1 MB 5.1 MB/s eta 0:00:04
------------------------- -------------- 31.5/50.1 MB 5.1 MB/s eta 0:00:04
------------------------- -------------- 31.7/50.1 MB 5.0 MB/s eta 0:00:04
------------------------- -------------- 32.0/50.1 MB 5.0 MB/s eta 0:00:04
------------------------- -------------- 32.1/50.1 MB 4.9 MB/s eta 0:00:04
------------------------- -------------- 32.5/50.1 MB 5.0 MB/s eta 0:00:04
-------------------------- ------------- 32.8/50.1 MB 5.0 MB/s eta 0:00:04
-------------------------- ------------- 33.0/50.1 MB 5.0 MB/s eta 0:00:04
-------------------------- ------------- 33.2/50.1 MB 5.0 MB/s eta 0:00:04
-------------------------- ------------- 33.5/50.1 MB 5.0 MB/s eta 0:00:04
-------------------------- ------------- 33.8/50.1 MB 5.1 MB/s eta 0:00:04
--------------------------- ------------ 34.0/50.1 MB 5.2 MB/s eta 0:00:04
--------------------------- ------------ 34.3/50.1 MB 5.2 MB/s eta 0:00:04
--------------------------- ------------ 34.4/50.1 MB 5.2 MB/s eta 0:00:04
--------------------------- ------------ 34.7/50.1 MB 5.1 MB/s eta 0:00:04
--------------------------- ------------ 34.9/50.1 MB 5.2 MB/s eta 0:00:03
--------------------------- ------------ 34.9/50.1 MB 5.2 MB/s eta 0:00:03
--------------------------- ------------ 34.9/50.1 MB 5.2 MB/s eta 0:00:03
--------------------------- ------------ 34.9/50.1 MB 5.2 MB/s eta 0:00:03
---------------------------- ----------- 35.4/50.1 MB 5.0 MB/s eta 0:00:03
---------------------------- ----------- 35.7/50.1 MB 5.2 MB/s eta 0:00:03
---------------------------- ----------- 36.0/50.1 MB 5.2 MB/s eta 0:00:03
---------------------------- ----------- 36.2/50.1 MB 5.2 MB/s eta 0:00:03
----------------------------- ---------- 36.5/50.1 MB 5.2 MB/s eta 0:00:03
----------------------------- ---------- 36.7/50.1 MB 5.2 MB/s eta 0:00:03
----------------------------- ---------- 37.0/50.1 MB 5.2 MB/s eta 0:00:03
----------------------------- ---------- 37.2/50.1 MB 5.2 MB/s eta 0:00:03
----------------------------- ---------- 37.4/50.1 MB 5.2 MB/s eta 0:00:03
------------------------------ --------- 37.7/50.1 MB 5.2 MB/s eta 0:00:03
------------------------------ --------- 37.9/50.1 MB 5.2 MB/s eta 0:00:03
------------------------------ --------- 38.1/50.1 MB 5.2 MB/s eta 0:00:03
------------------------------ --------- 38.3/50.1 MB 5.2 MB/s eta 0:00:03
------------------------------ --------- 38.6/50.1 MB 5.2 MB/s eta 0:00:03
------------------------------- -------- 39.0/50.1 MB 5.3 MB/s eta 0:00:03
------------------------------- -------- 39.1/50.1 MB 5.2 MB/s eta 0:00:03
------------------------------- -------- 39.3/50.1 MB 5.2 MB/s eta 0:00:03
------------------------------- -------- 39.5/50.1 MB 5.2 MB/s eta 0:00:03
------------------------------- -------- 39.8/50.1 MB 5.2 MB/s eta 0:00:02
------------------------------- -------- 40.0/50.1 MB 5.2 MB/s eta 0:00:02
-------------------------------- ------- 40.2/50.1 MB 5.2 MB/s eta 0:00:02
-------------------------------- ------- 40.4/50.1 MB 5.2 MB/s eta 0:00:02
-------------------------------- ------- 40.5/50.1 MB 5.1 MB/s eta 0:00:02
-------------------------------- ------- 40.8/50.1 MB 5.1 MB/s eta 0:00:02
-------------------------------- ------- 40.9/50.1 MB 5.0 MB/s eta 0:00:02
-------------------------------- ------- 41.1/50.1 MB 5.0 MB/s eta 0:00:02
--------------------------------- ------ 41.4/50.1 MB 5.0 MB/s eta 0:00:02
--------------------------------- ------ 41.6/50.1 MB 5.0 MB/s eta 0:00:02
--------------------------------- ------ 41.9/50.1 MB 5.1 MB/s eta 0:00:02
--------------------------------- ------ 42.2/50.1 MB 5.1 MB/s eta 0:00:02
---------------------------------- ----- 42.6/50.1 MB 5.2 MB/s eta 0:00:02
---------------------------------- ----- 42.8/50.1 MB 5.2 MB/s eta 0:00:02
---------------------------------- ----- 43.1/50.1 MB 5.2 MB/s eta 0:00:02
---------------------------------- ----- 43.4/50.1 MB 5.1 MB/s eta 0:00:02
---------------------------------- ----- 43.8/50.1 MB 5.2 MB/s eta 0:00:02
----------------------------------- ---- 43.9/50.1 MB 5.2 MB/s eta 0:00:02
----------------------------------- ---- 44.2/50.1 MB 5.1 MB/s eta 0:00:02
----------------------------------- ---- 44.5/50.1 MB 5.2 MB/s eta 0:00:02
----------------------------------- ---- 44.7/50.1 MB 5.1 MB/s eta 0:00:02
----------------------------------- ---- 44.9/50.1 MB 5.2 MB/s eta 0:00:01
------------------------------------ --- 45.3/50.1 MB 5.6 MB/s eta 0:00:01
------------------------------------ --- 45.4/50.1 MB 5.6 MB/s eta 0:00:01
------------------------------------ --- 45.6/50.1 MB 5.4 MB/s eta 0:00:01
------------------------------------ --- 45.7/50.1 MB 5.4 MB/s eta 0:00:01
------------------------------------ --- 46.0/50.1 MB 5.4 MB/s eta 0:00:01
------------------------------------ --- 46.1/50.1 MB 5.3 MB/s eta 0:00:01
------------------------------------- -- 46.6/50.1 MB 5.4 MB/s eta 0:00:01
------------------------------------- -- 46.9/50.1 MB 5.5 MB/s eta 0:00:01
------------------------------------- -- 47.2/50.1 MB 5.5 MB/s eta 0:00:01
------------------------------------- -- 47.4/50.1 MB 5.5 MB/s eta 0:00:01
------------------------------------- -- 47.5/50.1 MB 5.5 MB/s eta 0:00:01
-------------------------------------- - 47.8/50.1 MB 5.5 MB/s eta 0:00:01
-------------------------------------- - 47.9/50.1 MB 5.5 MB/s eta 0:00:01
-------------------------------------- - 48.0/50.1 MB 5.5 MB/s eta 0:00:01
-------------------------------------- - 48.2/50.1 MB 5.5 MB/s eta 0:00:01
-------------------------------------- - 48.4/50.1 MB 5.5 MB/s eta 0:00:01
-------------------------------------- - 48.7/50.1 MB 5.4 MB/s eta 0:00:01
-------------------------------------- - 48.8/50.1 MB 5.4 MB/s eta 0:00:01
--------------------------------------- 48.9/50.1 MB 5.3 MB/s eta 0:00:01
--------------------------------------- 49.0/50.1 MB 5.2 MB/s eta 0:00:01
--------------------------------------- 49.2/50.1 MB 5.2 MB/s eta 0:00:01
--------------------------------------- 49.4/50.1 MB 5.2 MB/s eta 0:00:01
--------------------------------------- 49.6/50.1 MB 5.2 MB/s eta 0:00:01
--------------------------------------- 49.8/50.1 MB 5.2 MB/s eta 0:00:01
--------------------------------------- 50.0/50.1 MB 5.2 MB/s eta 0:00:01
--------------------------------------- 50.1/50.1 MB 5.2 MB/s eta 0:00:01
--------------------------------------- 50.1/50.1 MB 5.2 MB/s eta 0:00:01
--------------------------------------- 50.1/50.1 MB 5.2 MB/s eta 0:00:01
---------------------------------------- 50.1/50.1 MB 4.8 MB/s eta 0:00:00
Downloading PyQt5-5.15.10-cp37-abi3-win_amd64.whl (6.8 MB)
---------------------------------------- 0.0/6.8 MB ? eta -:--:--
- -------------------------------------- 0.2/6.8 MB 6.3 MB/s eta 0:00:02
-- ------------------------------------- 0.4/6.8 MB 4.6 MB/s eta 0:00:02
-- ------------------------------------- 0.5/6.8 MB 4.0 MB/s eta 0:00:02
--- ------------------------------------ 0.6/6.8 MB 4.1 MB/s eta 0:00:02
---- ----------------------------------- 0.7/6.8 MB 3.7 MB/s eta 0:00:02
---- ----------------------------------- 0.8/6.8 MB 3.3 MB/s eta 0:00:02
----- ---------------------------------- 0.9/6.8 MB 3.5 MB/s eta 0:00:02
------ --------------------------------- 1.1/6.8 MB 3.3 MB/s eta 0:00:02
------- -------------------------------- 1.3/6.8 MB 3.5 MB/s eta 0:00:02
-------- ------------------------------- 1.5/6.8 MB 3.5 MB/s eta 0:00:02
--------- ------------------------------ 1.7/6.8 MB 3.7 MB/s eta 0:00:02
---------- ----------------------------- 1.8/6.8 MB 3.6 MB/s eta 0:00:02
----------- ---------------------------- 2.0/6.8 MB 3.7 MB/s eta 0:00:02
------------ --------------------------- 2.2/6.8 MB 3.7 MB/s eta 0:00:02
-------------- ------------------------- 2.4/6.8 MB 3.8 MB/s eta 0:00:02
--------------- ------------------------ 2.7/6.8 MB 3.8 MB/s eta 0:00:02
--------------- ------------------------ 2.7/6.8 MB 3.8 MB/s eta 0:00:02
----------------- ---------------------- 3.0/6.8 MB 3.9 MB/s eta 0:00:01
------------------ --------------------- 3.1/6.8 MB 3.9 MB/s eta 0:00:01
------------------- -------------------- 3.3/6.8 MB 3.9 MB/s eta 0:00:01
-------------------- ------------------- 3.5/6.8 MB 4.0 MB/s eta 0:00:01
--------------------- ------------------ 3.7/6.8 MB 4.0 MB/s eta 0:00:01
------------------------ --------------- 4.1/6.8 MB 4.2 MB/s eta 0:00:01
------------------------ --------------- 4.2/6.8 MB 4.0 MB/s eta 0:00:01
------------------------- -------------- 4.4/6.8 MB 4.2 MB/s eta 0:00:01
--------------------------- ------------ 4.7/6.8 MB 4.2 MB/s eta 0:00:01
---------------------------- ----------- 4.9/6.8 MB 4.2 MB/s eta 0:00:01
------------------------------ --------- 5.2/6.8 MB 4.3 MB/s eta 0:00:01
-------------------------------- ------- 5.6/6.8 MB 4.5 MB/s eta 0:00:01
---------------------------------- ----- 6.0/6.8 MB 4.6 MB/s eta 0:00:01
------------------------------------ --- 6.2/6.8 MB 4.6 MB/s eta 0:00:01
------------------------------------- -- 6.5/6.8 MB 4.7 MB/s eta 0:00:01
--------------------------------------- 6.8/6.8 MB 4.8 MB/s eta 0:00:01
---------------------------------------- 6.8/6.8 MB 4.7 MB/s eta 0:00:00
Downloading PyQt5_sip-12.13.0-cp311-cp311-win_amd64.whl (78 kB)
---------------------------------------- 0.0/78.5 kB ? eta -:--:--
---------------------------------------- 78.5/78.5 kB ? eta 0:00:00
Installing collected packages: PyQt5-Qt5, PyQt5-sip, PyQt5
Successfully installed PyQt5-5.15.10 PyQt5-Qt5-5.15.2 PyQt5-sip-12.13.0
%% Cell type:markdown id: tags:
## Usage
%% Cell type:code id: tags:
``` python
import gym
import time
# Create the environment
env = gym.make("CartPole-v1", render_mode="human")
# Reset the environment and get the initial observation
observation = env.reset()
for _ in range(1000):
# Select a random action from the action space
action = env.action_space.sample()
# Apply the action to the environment
# Returns next observation, reward, done signal (indicating
# if the episode has ended), and an additional info dictionary
observation, reward, terminated, truncated, info = env.step(action)
# Render the environment to visualize the agent's behavior
env.render()
if terminated:
# Terminated before max step
break
time.sleep(0.2) # Sleep added to slow down the visualization
env.close()
```
%% Cell type:markdown id: tags:
## Reinforce
## Upload model to Hugging Face hub
%% Cell type:markdown id: tags:
%% Cell type:code id: tags:
``` python
from huggingface_sb3 import package_to_hub, push_to_hub
package_to_hub(model=model,
model_name="a2c-CartPole-v1",
model_architecture="a2c",
env_id="CartPole-v1",
eval_env=None,
repo_id="oscarchaufour/a2c-CartPole-v1",
commit_message="Test commit")
push_to_hub(repo_id="oscarchaufour/a2c-CartPole-v1",
filename="a2c_sb3_cartpole.zip",
commit_message="Added A2C CartPole model")
```
%% Output
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[8], line 3
1 from huggingface_sb3 import package_to_hub, push_to_hub
----> 3 package_to_hub(model=model,
4 model_name="a2c-CartPole-v1",
5 model_architecture="a2c",
6 env_id="CartPole-v1",
7 eval_env=None,
8 repo_id="oscarchaufour/a2c-CartPole-v1",
9 commit_message="Test commit")
11 push_to_hub(repo_id="oscarchaufour/a2c-CartPole-v1",
12 filename="a2c_sb3_cartpole.zip",
13 commit_message="Added A2C CartPole model")
NameError: name 'model' is not defined
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment