Skip to content

Commit

Permalink
Fix visualisation imports in notebooks
Browse files Browse the repository at this point in the history
See #522
  • Loading branch information
eleurent committed Oct 22, 2023
1 parent 085f8c8 commit 8d93240
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 220 deletions.
64 changes: 32 additions & 32 deletions scripts/highway_planning.ipynb
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "highway-planning.ipynb",
"provenance": []
},
"kernelspec": {
"name": "python3",
"language": "python",
"display_name": "Python 3"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"source": [],
"metadata": {
"collapsed": false
}
}
}
},
"cells": [
{
"cell_type": "markdown",
Expand All @@ -35,9 +13,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "s-ghXis6A_md"
},
"outputs": [],
"source": [
"#@title Imports for env, agent, and visualisation.\n",
"# Environment\n",
Expand All @@ -55,19 +35,19 @@
"!pip install moviepy -U\n",
"!pip install imageio_ffmpeg\n",
"!pip install pyvirtualdisplay\n",
"!apt-get install -y xvfb python-opengl ffmpeg\n",
"!git clone https://github.com/eleurent/highway-env.git\n",
"!apt-get install -y xvfb ffmpeg\n",
"!git clone https://github.com/Farama-Foundation/HighwayEnv.git\n",
"sys.path.insert(0, './highway-env/scripts/')\n",
"from utils import record_videos, show_videos\n"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bgNDDWwqCj8l"
},
"outputs": [],
"source": [
"#@title Run an episode\n",
"\n",
Expand All @@ -92,9 +72,29 @@
" \n",
"env.close()\n",
"show_videos()"
],
"execution_count": null,
"outputs": []
]
}
],
"metadata": {
"colab": {
"name": "highway-planning.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"metadata": {
"collapsed": false
},
"source": []
}
}
]
}
},
"nbformat": 4,
"nbformat_minor": 0
}
84 changes: 42 additions & 42 deletions scripts/intersection_social_dqn.ipynb
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "SocialAttentionDQN",
"provenance": []
},
"kernelspec": {
"name": "python3",
"language": "python",
"display_name": "Python 3"
},
"accelerator": "GPU",
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"source": [],
"metadata": {
"collapsed": false
}
}
}
},
"cells": [
{
"cell_type": "markdown",
Expand All @@ -35,9 +12,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Kx8X4s8krNWt"
},
"outputs": [],
"source": [
"#@title Import requirements\n",
"\n",
Expand All @@ -54,13 +33,11 @@
"import sys\n",
"%load_ext tensorboard\n",
"!pip install tensorboardx gym pyvirtualdisplay\n",
"!apt-get install -y xvfb python-opengl ffmpeg\n",
"!git clone https://github.com/eleurent/highway-env.git 2> /dev/null\n",
"!apt-get install -y xvfb ffmpeg\n",
"!git clone https://github.com/Farama-Foundation/HighwayEnv.git 2> /dev/null\n",
"sys.path.insert(0, '/content/highway-env/scripts/')\n",
"from utils import show_videos"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -75,9 +52,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "QowKW3ix45ZW"
},
"outputs": [],
"source": [
"#@title Prepare environment, agent, and evaluation process.\n",
"\n",
Expand All @@ -96,9 +75,7 @@
"agent = load_agent(agent_config, env)\n",
"evaluation = Evaluation(env, agent, num_episodes=NUM_EPISODES, display_env=False, display_agent=False)\n",
"print(f\"Ready to train {agent} on {env}\")"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -111,14 +88,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "q7QJY2wc4_1N"
},
"outputs": [],
"source": [
"%tensorboard --logdir \"{evaluation.directory}\""
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -131,14 +108,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "sFVq1gFz42Eg"
},
"outputs": [],
"source": [
"evaluation.train()"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand All @@ -160,9 +137,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "gY0rpVYUtRpN"
},
"outputs": [],
"source": [
"#@title Run the learned policy for a few episodes.\n",
"env = load_environment(env_config)\n",
Expand All @@ -171,9 +150,30 @@
"evaluation = Evaluation(env, agent, num_episodes=1)\n",
"evaluation.train()\n",
"show_videos(evaluation.run_directory)"
],
"execution_count": null,
"outputs": []
]
}
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"name": "SocialAttentionDQN",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"metadata": {
"collapsed": false
},
"source": []
}
}
},
"nbformat": 4,
"nbformat_minor": 0
}
32 changes: 16 additions & 16 deletions scripts/parking_her.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "bzMSuJEOfviP",
"pycharm": {
"is_executing": false,
"name": "#%%\n"
},
"cellView": "form"
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -54,36 +54,36 @@
"import sys\n",
"from tqdm.notebook import trange\n",
"!pip install tensorboardx gym pyvirtualdisplay\n",
"!apt-get install -y xvfb python-opengl ffmpeg\n",
"!git clone https://github.com/eleurent/highway-env.git 2> /dev/null\n",
"!apt-get install -y xvfb ffmpeg\n",
"!git clone https://github.com/Farama-Foundation/HighwayEnv.git 2> /dev/null\n",
"sys.path.insert(0, '/content/highway-env/scripts/')\n",
"from utils import record_videos, show_videos"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "frgfxpsP3fFn"
},
"outputs": [],
"source": [
"#@title Tensorboard - click the refresh button once training is running\n",
"\n",
"%load_ext tensorboard\n",
"%tensorboard --logdir logs"
],
"metadata": {
"cellView": "form",
"id": "frgfxpsP3fFn"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "Y5TOvonYqP-g",
"pycharm": {
"name": "#%% \n"
},
"cellView": "form"
}
},
"outputs": [],
"source": [
Expand All @@ -108,11 +108,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "xOcOP7Of18T2",
"pycharm": {
"name": "#%%\n"
},
"cellView": "form"
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -173,4 +173,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
Loading

0 comments on commit 8d93240

Please sign in to comment.