What's the benefit of relying on pytorch.hub.load() vs. publishing as a pip package?

I’ve started messing around with PyTorch, specifically importing models via torch.hub.load(). After taking a look at what the function actually does, though, I realized it basically acts as if the repo was installed as a module (it even states much in the documentation: “Torch hub works by importing the package as if it was installed”).

But… I now don’t entirely understand why PyTorch adopted this faux-install model instead of suggesting creators follow the standard Python route of publishing their models as packages on PyPI and/or Conda, especially given how the package sizes aren’t that large (the vast majority of models I’ve found download their weights from an external source instead of including them in the repo itself).

Basically, why did PyTorch go for:

model = torch.hub.load("user/repo", "buzz")

instead of the more common:

from repo import buzz
model = buzz()

Was it to keep things simple for the model creators, not having to figure out the complexities of setup.py/pyproject.toml, how to publish to the indexes, etc?

Which is the correct approach as source code repositories should not store binary data apart from a few exceptions.

torch.hub is an easy approach to load supported (and reviewed) models that can be easily used in e.g. CI runs without installing 3rd party dependencies. You can of course still install 3rd party libs if you prefer this approach or is a model is not available in the hub.

Ah, wait, does torch.hub only work with projects in the PyTorch Hub? Or, rather, the “metadata” functions such as hub.list() will only present projects registered in pytorch/hub, but AFAICT from looking at it’s source code, pytorch.load() actually lets you load any repo with a hubconf.py.

And, for what it’s worth, the PyTorch Hub documentation doesn’t suggest registering in pytorch/hub, just adding the hubconf.py.

That’s sort of my question, though… isn’t torch.hub.load() effectively installing a 3rd party dependency as well? I don’t see the difference between it and using pip install: Both download the source code, run a “setup” Python script (hubconf.py vs. setup.py) and then load the module (torch.hub._load_module() – which is called by .load() – vs. from repo import model).

You might be right and it seems I have overestimated the process of adding models into the hub based on your explanation. In this case, it seems it might just be a convenient wrapper to load models in your script instead of installing it from your terminal.