How to get total number for downloads for a model

How can I know the total number for downloads of any model?

models = hf_api.list_models()

for model in models:
downloads = model.downloads if hasattr(model, ‘downloads’) else 0

is the download count returned my list_models APIs is total downloads and last weeks downloads ?

I believe you can make a call to their API.

https://huggingface.co/api/models/<username>/<repo>?expand%5B%5D=downloads&expand%5B%5D=downloadsAllTime

For example:

https://huggingface.co/api/models/openai/clip-vit-large-patch14?expand[]=downloads&expand[]=downloadsAllTime

1 Like