huggingface / huggingface_hub

The official Python client for the Huggingface Hub.
https://huggingface.co/docs/huggingface_hub
Apache License 2.0
2.1k stars 550 forks source link

How to correctly upload 160 RL models? #769

Closed simoninithomas closed 2 years ago

simoninithomas commented 2 years ago

Hi! For people who upload a lot of models on the Hub, I'm working on the upload of about 160 RL models (rl-trained-agents) :fire: so I will not do it by hand :sweat_smile:

The github repository containing all the models is like this:

rl-trained-agents
   /a2c/Acrobot-v1_1
   /a2c/CartPole-v1_1
   ...
   /ppo/CartPOle-v1_1

Each model is like this (for instance /ppo/SpaceInvadersNoFrameskip-v4:

├── SpaceInvadersNoFrameskip-v4_1/
│   ├── SpaceInvadersNoFrameskip-v4.zip
│   ├── monitor.csv
│   ├── evaluations.npz        
│   ├── SpaceInvadersNoFrameskip-v4/
│     ├── args.yml
│     ├── config.yml
│     ├── vecnormalize.pkl

The process I'm defining is this way (pseudocode) for each {algo}/{env_id}:

# Step 1: Create Repo on the Hub using Repository
sb3/{algo}-{env_id}: for instance `sb3/ppo-CartPole-v1`

# Step 2: Clone the Repo to a folder

# Step 3: Move the corresponding rl-trained-agents/algo/env to Repo

# Step 4: Go to the Repo and generate the model card

# Step 5: Generate the video (using a script)

# Step 6: Push to Hub the repo

Do you think it's a good process or you have some better solutions? Thanks for your feedback

simoninithomas commented 2 years ago

@osanseviero : "Then the approach sounds good. One suggestion to avoid having to do this twice, is that I would unzip the files. Having them within a zip is not great I feel, specially since you have 0 idea what is in there without download+unzipping (similar to how we discussed spaCy works atm)"

So the described process is only for SB team models.

The idea is:

enjoy.py:

if not found then:
  local_dir = f"rl-trained-agents/{algo}/{env_id}_1"
  clone_from = f"sb3/{algo}-{env_id}"
  repo = Repository(local_dir, clone_from)

I try the environment

!python enjoy.py --algo ppo --env CartPole-v1 --no-render


But for these official saved models, we just modify one line of code of enjoy.py (if the folder is not found and the model searched is from rl-trained-agents then download it from the hub) that's why we can put it directly on rl-baselines-zoo without having an external repo like huggingface_sb3
osanseviero commented 2 years ago

This is super cool, really looking forward to this!

julien-c commented 2 years ago

i agree that you should store the uncompressed files whenever possible (to get git history etc)

adrinjalali commented 2 years ago

Is this issue resolved? Can we close this?

osanseviero commented 2 years ago

Yes, this is more of a discussion on good practices rather than an issue with the core library. This info will be useful for the new docs as well cc @NimaBoscarino