Update with official ML-Agents integration

This commit is contained in:
Thomas Simonini
2023-06-08 12:05:49 +02:00
parent b914972189
commit b669edb994

View File

@@ -68,9 +68,7 @@
"\n",
"### 📚 RL-Library: \n",
"\n",
"- [ML-Agents (HuggingFace Experimental Version)](https://github.com/huggingface/ml-agents)\n",
"\n",
"⚠ We're going to use an experimental version of ML-Agents were you can push to hub and load from hub Unity ML-Agents Models **you need to install the same version**"
"- [ML-Agents](https://github.com/Unity-Technologies/ml-agents)\n"
],
"metadata": {
"id": "A-cYE0K5iL-w"
@@ -146,9 +144,7 @@
"source": [
"# Let's train our agents 🚀\n",
"\n",
"The ML-Agents integration on the Hub is **still experimental**, some features will be added in the future. \n",
"\n",
"But for now, **to validate this hands-on for the certification process, you just need to push your trained models to the Hub**. Theres no results to attain to validate this one. But if you want to get nice results you can try to attain:\n",
"**To validate this hands-on for the certification process, you just need to push your trained models to the Hub**. Theres no results to attain to validate this one. But if you want to get nice results you can try to attain:\n",
"\n",
"- For `Pyramids` : Mean Reward = 1.75\n",
"- For `SnowballTarget` : Mean Reward = 15 or 30 targets hit in an episode.\n"
@@ -186,8 +182,7 @@
"id": "an3ByrXYQ4iK"
},
"source": [
"## Clone the repository and install the dependencies 🔽\n",
"- We need to clone the repository, that **contains the experimental version of the library that allows you to push your trained agent to the Hub.**"
"## Clone the repository and install the dependencies 🔽\n"
]
},
{
@@ -200,7 +195,7 @@
"source": [
"%%capture\n",
"# Clone the repository\n",
"!git clone --depth 1 --branch hf-integration-save https://github.com/huggingface/ml-agents"
"!git clone --depth 1 https://github.com/Unity-Technologies/ml-agents"
]
},
{
@@ -218,19 +213,6 @@
"!pip3 install -e ./ml-agents"
]
},
{
"cell_type": "code",
"source": [
"%%capture\n",
"# Due to some conflicts between mlagents and tensorflow we need to uninstall it\n",
"!pip3 uninstall tensorflow -y"
],
"metadata": {
"id": "ozcA_tl_XTrv"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
@@ -521,7 +503,7 @@
{
"cell_type": "code",
"source": [
"!mlagents-push-to-hf --run-id=\"SnowballTarget1\" --local-dir=\"./results/SnowballTarget2\" --repo-id=\"ThomasSimonini/ppo-SnowballTargetTESTCOLAB\" --commit-message=\"First Push\""
"!mlagents-push-to-hf --run-id=\"SnowballTarget1\" --local-dir=\"./results/SnowballTarget1\" --repo-id=\"ThomasSimonini/ppo-SnowballTarget\" --commit-message=\"First Push\""
],
"metadata": {
"id": "kAFzVB7OYj_H"
@@ -575,7 +557,7 @@
"\n",
"1. Remember your repo-id\n",
"\n",
"2. Go here: https://singularite.itch.io/snowballtarget\n",
"2. Go here: https://huggingface.co/spaces/ThomasSimonini/ML-Agents-SnowballTarget\n",
"\n",
"3. Launch the game and put it in full screen by clicking on the bottom right button\n",
"\n",
@@ -761,15 +743,6 @@
"- Now that we trained our agent, were **ready to push it to the Hub to be able to visualize it playing on your browser🔥.**"
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "JZ53caJ99sX_"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
@@ -786,7 +759,7 @@
"source": [
"### Watch your agent playing 👀\n",
"\n",
"The temporary link for Pyramids demo is: https://singularite.itch.io/pyramids"
"👉 https://huggingface.co/spaces/unity/ML-Agents-Pyramids"
],
"metadata": {
"id": "7aZfgxo-CDeQ"
@@ -798,7 +771,7 @@
"### 🎁 Bonus: Why not train on another environment?\n",
"Now that you know how to train an agent using MLAgents, **why not try another environment?** \n",
"\n",
"MLAgents provides 18 different and were building some custom ones. The best way to learn is to try things of your own, have fun.\n",
"MLAgents provides 17 different and were building some custom ones. The best way to learn is to try things of your own, have fun.\n",
"\n"
],
"metadata": {
@@ -817,15 +790,13 @@
{
"cell_type": "markdown",
"source": [
"You have the full list of the one currently available on Hugging Face here 👉 https://github.com/huggingface/ml-agents#the-environments\n",
"You have the full list of the Unity official environments here 👉 https://github.com/Unity-Technologies/ml-agents/blob/develop/docs/Learning-Environment-Examples.md\n",
"\n",
"For the demos to visualize your agent, the temporary link is: https://singularite.itch.io (temporary because we'll also put the demos on Hugging Face Space)\n",
"For the demos to visualize your agent 👉 https://huggingface.co/unity\n",
"\n",
"For now we have integrated: \n",
"- [Worm](https://singularite.itch.io/worm) demo where you teach a **worm to crawl**.\n",
"- [Walker](https://singularite.itch.io/walker) demo where you teach an agent **to walk towards a goal**.\n",
"\n",
"If you want new demos to be added, please open an issue: https://github.com/huggingface/deep-rl-class 🤗"
"- [Worm](https://huggingface.co/spaces/unity/ML-Agents-Worm) demo where you teach a **worm to crawl**.\n",
"- [Walker](https://huggingface.co/spaces/unity/ML-Agents-Walker) demo where you teach an agent **to walk towards a goal**."
],
"metadata": {
"id": "YiyF4FX-04JB"
@@ -836,7 +807,7 @@
"source": [
"Thats all for today. Congrats on finishing this tutorial!\n",
"\n",
"The best way to learn is to practice and try stuff. Why not try another environment? ML-Agents has 18 different environments, but you can also create your own? Check the documentation and have fun!\n",
"The best way to learn is to practice and try stuff. Why not try another environment? ML-Agents has 17 different environments, but you can also create your own? Check the documentation and have fun!\n",
"\n",
"See you on Unit 6 🔥,\n",
"\n",
@@ -865,4 +836,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}