Get Model

foolbox.zoo.get_model(url, module_name='foolbox_model', overwrite=False, **kwargs)

Download a Foolbox-compatible model from the given Git repository URL.


Instantiate a model:

>>> from foolbox import zoo
>>> url = ""
>>> model = zoo.get_model(url)  

Only works with a foolbox-zoo compatible repository. I.e. models need to have a file with a create()-function, which returns a foolbox-wrapped model.

Using the kwargs parameter it is possible to input an arbitrary number of parameters to this methods call. These parameters are forwarded to the instantiated model.

Example repositories:

  • url (str) – URL to the git repository.

  • module_name (str) – The name of the module to import.

  • kwargs (Any) – Optional set of parameters that will be used by the to be instantiated model.

  • overwrite (bool) –


A Foolbox-wrapped model instance.

Return type


Fetch Weights

foolbox.zoo.fetch_weights(weights_uri, unzip=False)

Provides utilities to download and extract packages containing model weights when creating foolbox-zoo compatible repositories, if the weights are not part of the repository itself.


Download and unzip weights:

>>> from foolbox import zoo
>>> url = ''  # noqa F501
>>> weights_path = zoo.fetch_weights(url, unzip=True)
  • weights_uri (str) – The URI to fetch the weights from.

  • unzip (bool) – Should be True if the file to be downloaded is a zipped package.


Local path where the weights have been downloaded and potentially unzipped to.

Return type