Model Class

class modelindex.models.Model.Model(name: Optional[str] = None, metadata: Optional[Union[Dict, modelindex.models.Metadata.Metadata, str]] = None, results: Optional[Union[List, modelindex.models.ResultList.ResultList, modelindex.models.Result.Result, Dict, str]] = None, paper: Optional[Union[str, Dict]] = None, code: Optional[str] = None, weights: Optional[str] = None, config: Optional[str] = None, readme: Optional[str] = None, in_collection: Optional[Union[str, List[str]]] = None, image: Optional[str] = None, _filepath: Optional[str] = None, _path_to_readme: Optional[str] = None, **kwargs)[source]

Model represents the ML model.

Parameters
  • name (str) – Name of the model

  • metadata (Metadata, dict, str) – Metadata object, metadata dict or a filepath to the metadata file

  • results (ResultList, Result, list, dict, str) – ResultList, a single Results, a list of result dicts, a single result dict, or a filepath to the result file

  • paper (str, dict) – URL to the paper, or a structured dict with paper metadata (title, url)

  • code (str) – URL to the code snippet

  • weights (str) – URL to the pretrained weights

  • config (str) – URL to the config file

  • readme (str) – path to the README file for the model

  • in_collection (str, List) – name of the collection to which the model belongs to

  • image (str) – path or URL to an image for the model

  • _filepath – The file path to where the data was loaded from

  • _path_to_readme – Path to the markdown readme file if data is coming from there

  • **kwargs – Any other custom fields

__init__(name: Optional[str] = None, metadata: Optional[Union[Dict, modelindex.models.Metadata.Metadata, str]] = None, results: Optional[Union[List, modelindex.models.ResultList.ResultList, modelindex.models.Result.Result, Dict, str]] = None, paper: Optional[Union[str, Dict]] = None, code: Optional[str] = None, weights: Optional[str] = None, config: Optional[str] = None, readme: Optional[str] = None, in_collection: Optional[Union[str, List[str]]] = None, image: Optional[str] = None, _filepath: Optional[str] = None, _path_to_readme: Optional[str] = None, **kwargs)[source]
Parameters
  • name (str) – Name of the model

  • metadata (Metadata, dict, str) – Metadata object, metadata dict or a filepath to the metadata file

  • results (ResultList, Result, list, dict, str) – ResultList, a single Results, a list of result dicts, a single result dict, or a filepath to the result file

  • paper (str, dict) – URL to the paper, or a structured dict with paper metadata (title, url)

  • code (str) – URL to the code snippet

  • weights (str) – URL to the pretrained weights

  • config (str) – URL to the config file

  • readme (str) – path to the README file for the model

  • in_collection (str, List) – name of the collection to which the model belongs to

  • image (str) – path or URL to an image for the model

  • _filepath – The file path to where the data was loaded from

  • _path_to_readme – Path to the markdown readme file if data is coming from there

  • **kwargs – Any other custom fields

classmethod from_dict(d: Dict, _filepath: Optional[str] = None, _path_to_readme: Optional[str] = None)[source]

Create a Model from a dictionary.

Parameters
  • d (dict) – dictionary containing models data

  • _filepath (str) – The file path to where the data was loaded from

  • _path_to_readme (str) – Path to the README file if metadata was extracted from a README

static from_file(filepath: Optional[str] = None, parent_filepath: Optional[str] = None)[source]

Load a Model from a file.

Parameters
  • filepath (str) – File from which to load the model

  • parent_filepath (str) – Parent filename (if file is imported from another file)

readme_content()[source]

Get the content of the README file (instead of just the path as returned by .readme())

property full_model

Get the model with all the inherited properties from the collection (read-only property)

property name

Get the model name

property paper

Get the model paper

property code

Get the URL to code

property weights

Get the URL to weights

property config

Get the URL to the config file

property readme

Get the path to the model README

property in_collection

Get the name of the collection of which this model is part of.

property image

Get the path or URL to the image for the model

property metadata

Get the metadata as a Metadata object

property results

Get the results as a Result object