API Documentation

install

mim.commands.install.infer_find_url(package: str) → str[source]

Try to infer find_url if possible.

If package is the official package, the find_url can be inferred.

Parameters

package (str) – The name of package, such as mmcls.

mim.commands.install.install(package: str, find_url: str = '', timeout: int = 15, is_yes: bool = False, is_user_dir: bool = False) → None[source]

Install a package by wheel or from github.

Parameters
  • package (str) – The name of installed package, such as mmcls.

  • find_url (str) – Url for finding package. If finding is not provided, program will infer the find_url as much as possible. Default: ‘’.

  • timeout (int) – The socket timeout. Default: 15.

  • is_yes (bool) – Don’t ask for confirmation of uninstall deletions. Default: False.

  • is_usr_dir (bool) – Install to the Python user install directory for environment variables and user configuration. Default: False.

mim.commands.install.install_dependencies(dependencies: List[List[str]], timeout: int = 15, is_yes: bool = False, is_user_dir: bool = False) → None[source]

Install dependencies, such as mmcls depends on mmcv.

Parameters
  • dependencies (list) – The list of denpendency.

  • timeout (int) – The socket timeout. Default: 15.

  • is_yes (bool) – Don’t ask for confirmation of uninstall deletions. Default: False.

  • is_usr_dir (bool) – Install to the Python user install directory for environment variables and user configuration. Default: False.

mim.commands.install.install_from_github(package: str, version: str = '', find_url: str = '', timeout: int = 15, is_yes: bool = False, is_user_dir: bool = False, is_install_master: bool = False) → None[source]

Install package from github.

Parameters
  • package (str) – The name of installed package, such as mmcls.

  • version (str) – Version of package. Default: ‘’.

  • find_url (str) – Url for finding package. If finding is not provided, program will infer the find_url as much as possible. Default: ‘’.

  • timeout (int) – The socket timeout. Default: 15.

  • is_yes (bool) – Don’t ask for confirmation of uninstall deletions. Default: False.

  • is_usr_dir (bool) – Install to the Python user install directory for environment variables and user configuration. Default: False.

  • is_install_master (bool) – Whether install master branch. If it is True, process will install master branch. If it is False, process will install the specified version. Default: False.

mim.commands.install.install_from_repo(repo_root: str, *, package: str = '', timeout: int = 15, is_yes: bool = False, is_user_dir: bool = False)[source]

Install package from local repo.

Parameters
  • repo_root (str) – The root of repo.

  • package (str) – The name of installed package. Default: ‘’.

  • timeout (int) – The socket timeout. Default: 15.

  • is_yes (bool) – Don’t ask for confirmation of uninstall deletions. Default: False.

  • is_usr_dir (bool) – Install to the Python user install directory for environment variables and user configuration. Default: False.

mim.commands.install.install_from_wheel(package: str, version: str = '', find_url: str = '', timeout: int = 15, is_user_dir: bool = False) → None[source]

Install wheel from find_url.

Parameters
  • package (str) – The name of installed package, such as mmcls.

  • version (str) – Version of package. Default: ‘’.

  • find_url (str) – Url for finding package. If finding is not provided, program will infer the find_url as much as possible. Default: ‘’.

  • timeout (int) – The socket timeout. Default: 15.

  • is_usr_dir (bool) – Install to the Python user install directory for environment variables and user configuration. Default: False.

mim.commands.install.parse_dependencies(path: str) → list[source]

Parse dependencies from repo/requirements/mminstall.txt.

Parameters

path (str) – Path of mminstall.txt.

uninstall

mim.commands.uninstall.uninstall(package: str, confirm_yes=False) → None[source]

Uninstall package.

Parameters
  • package (str) – The name of uninstalled package, such as mmcv-full.

  • confirm_yes (bool) – Don’t ask for confirmation of uninstall deletions. Default: True.

list

mim.commands.list.list_package(all: bool = False) → List[List[str]][source]

List packages.

List packages of OpenMMLab projects or all the packages in the python environment.

Parameters

all (bool) – List all installed packages. If all is False, it just lists the packages installed by mim. Default: False.

search

mim.commands.search.convert2df(metadata: modelindex.models.ModelIndex.ModelIndex) → pandas.core.frame.DataFrame[source]

Convert metadata into DataFrame format.

mim.commands.search.dump2json(dataframe: pandas.core.frame.DataFrame, json_path: str) → None[source]

Dump data frame of meta data into JSON.

Parameters
  • dataframe (DataFrame) – Data to be filtered.

  • json_path (str) – Dump output to json_path.

mim.commands.search.filter_by_conditions(dataframe: pandas.core.frame.DataFrame, filter_conditions: Optional[str] = None) → pandas.core.frame.DataFrame[source]

Filter rows with conditions.

Parameters
  • dataframe (DataFrame) – Data to be filtered.

  • filter_conditions (str, optional) – Conditions to filter. Default: None.

mim.commands.search.filter_by_configs(dataframe: pandas.core.frame.DataFrame, configs: Optional[List[str]] = None) → pandas.core.frame.DataFrame[source]

Filter by configs.

Parameters
  • dataframe (DataFrame) – Data to be filtered.

  • configs (List[str], optional) – Config ids to query. Default: None.

mim.commands.search.filter_by_models(dataframe: pandas.core.frame.DataFrame, models: Optional[List[str]] = None) → pandas.core.frame.DataFrame[source]

Filter by models.

Parameters
  • dataframe (DataFrame) – Data to be filtered.

  • models (List[str], optional) – Models to query. Default: None.

mim.commands.search.filter_by_training_datasets(dataframe: pandas.core.frame.DataFrame, datasets: Optional[List[str]]) → pandas.core.frame.DataFrame[source]

Filter by training datasets.

Parameters
  • dataframe (DataFrame) – Data to be filtered.

  • datasets (List[str], optional) – Training datasets to query. Default: None.

mim.commands.search.get_model_info(package: str, configs: Optional[List[str]] = None, models: Optional[List[str]] = None, training_datasets: Optional[List[str]] = None, filter_conditions: Optional[str] = None, sorted_fields: Optional[List[str]] = None, ascending: bool = True, shown_fields: Optional[List[str]] = None, unshown_fields: Optional[List[str]] = None, local: bool = True, to_dict: bool = False) → Any[source]

Get model information like metric or dataset.

Parameters
  • package (str) – Name of package to load metadata.

  • configs (List[str], optional) – Config ids to query. Default: None.

  • models (List[str], optional) – Models to query. Default: None.

  • training_datasets (List[str], optional) – Training datasets to query. Default: None.

  • filter_conditions (str, optional) – Conditions to filter. Default: None.

  • sorted_fields (List[str], optional) – Sort output by sorted_fields. Default: None.

  • ascending (bool) – Sort by ascending or descending. Default: True.

  • shown_fields (List[str], optional) – Fields to be outputted. Default: None.

  • unshown_fields (List[str], optional) – Fields to be hidden. Default: None.

  • local (bool) – Query from local environment or remote github. Default: True.

  • to_dict (bool) – Convert dataframe into dict. Default: False.

mim.commands.search.load_metadata(package: str, local: bool = True) → Optional[modelindex.models.ModelIndex.ModelIndex][source]

Load metadata from local package or remote package.

Parameters
  • package (str) – Name of package to load metadata.

  • local (bool) – Query from local environment or remote github. Default: True.

mim.commands.search.load_metadata_from_local(package: str)[source]

Load metadata from local package.

Parameters

package (str) – Name of package to load metadata.

Example

>>> metadata = load_metadata_from_local('mmcls')
mim.commands.search.load_metadata_from_remote(package: str) → Optional[modelindex.models.ModelIndex.ModelIndex][source]

Load metadata from github.

Download the model_zoo directory from github and parse it into metadata.

Parameters

package (str) – Name of package to load metadata.

Example

>>> # load metadata from master branch
>>> metadata = load_metadata_from_remote('mmcls')
>>> # load metadata from 0.11.0
>>> metadata = load_metadata_from_remote('mmcls==0.11.0')
mim.commands.search.print_df(dataframe: pandas.core.frame.DataFrame) → None[source]

Print Dataframe into terminal.

mim.commands.search.select_by(dataframe: pandas.core.frame.DataFrame, shown_fields: Optional[List[str]] = None, unshown_fields: Optional[List[str]] = None) → pandas.core.frame.DataFrame[source]

Select by the fields.

Parameters
  • dataframe (DataFrame) – Data to be filtered.

  • shown_fields (List[str], optional) – Fields to be outputted. Default: None.

  • unshown_fields (List[str], optional) – Fields to be hidden. Default: None.

mim.commands.search.sort_by(dataframe: pandas.core.frame.DataFrame, sorted_fields: Optional[List[str]], ascending: bool = True) → pandas.core.frame.DataFrame[source]

Sort by the fields.

Parameters
  • dataframe (DataFrame) – Data to be sorted.

  • sorted_fields (List[str], optional) – Sort output by sorted_fields. Default: None.

  • ascending (bool) – Sort by ascending or descending. Default: True.

download

mim.commands.download.download(package: str, configs: List[str], dest_root: Optional[str] = None) → List[str][source]

Download checkpoints from url and parse configs from package.

Parameters
  • package (str) – Name of pakcage.

  • configs (List[str]) – List of config ids.

  • dest_root (Optional[str]) – Destination directory to save checkpoint and config. Default: None.

train

mim.commands.train.train(package: str, config: str, gpus: int, gpus_per_node: int = None, cpus_per_task: int = 2, partition: str = None, launcher: str = 'none', port: int = None, srun_args: Optional[str] = None, other_args: tuple = ()) → Tuple[bool, Union[str, Exception]][source]

Train a model with given config.

Parameters
  • package (str) – The codebase name.

  • config (str) – The config file path. If not exists, will search in the config files of the codebase.

  • gpus (int) – Number of gpus used for training.

  • gpus_per_node (int, optional) – Number of gpus per node to use (only applicable to launcher == “slurm”). Defaults to None.

  • cpus_per_task (int, optional) – Number of cpus per task to use (only applicable to launcher == “slurm”). Defaults to None.

  • partition (str, optional) – The partition name (only applicable to launcher == “slurm”). Defaults to None.

  • launcher (str, optional) – The launcher used to launch jobs. Defaults to ‘none’.

  • port (int | None, optional) – The port used for inter-process communication (only applicable to slurm / pytorch launchers). Default to None. If set to None, will randomly choose a port between 20000 and 30000.

  • srun_args (str, optional) – Other srun arguments that might be used, all arguments should be in a string. Defaults to None.

  • other_args (tuple, optional) – Other arguments, will be passed to the codebase’s training script. Defaults to ().

test

mim.commands.test.test(package: str, config: str, checkpoint: str = None, gpus: int = None, gpus_per_node: int = None, cpus_per_task: int = 2, partition: str = None, launcher: str = 'none', port: int = None, srun_args: Optional[str] = None, other_args: tuple = ()) → Tuple[bool, Union[str, Exception]][source]

Test a model with given config.

Parameters
  • package (str) – The codebase name.

  • config (str) – The config file path. If not exists, will search in the config files of the codebase.

  • checkpoint (str) – The path to the checkpoint file. Default to None.

  • gpus (int) – Number of gpus used for testing (only applicable to launcher == “slurm”). Defaults to None.

  • gpus_per_node (int, optional) – Number of gpus per node to use (only applicable to launcher == “slurm”). Defaults to None.

  • cpus_per_task (int, optional) – Number of cpus per task to use (only applicable to launcher == “slurm”). Defaults to None.

  • partition (str, optional) – The partition name (only applicable to launcher == “slurm”). Defaults to None.

  • launcher (str, optional) – The launcher used to launch jobs. Defaults to ‘none’.

  • port (int | None, optional) – The port used for inter-process communication (only applicable to slurm / pytorch launchers). Default to None. If set to None, will randomly choose a port between 20000 and 30000.

  • srun_args (str, optional) – Other srun arguments that might be used, all arguments should be in a string. Defaults to None.

  • other_args (tuple, optional) – Other arguments, will be passed to the codebase’s training script. Defaults to ().

run

mim.commands.run.run(package: str, command: str, other_args: tuple = ()) → Tuple[bool, Union[str, Exception]][source]

Run arbitrary command of a codebase.

This command assumes the command scripts have been put into the package/tools directory.

Parameters
  • package (str) – The codebase name.

  • other_args (tuple, optional) – Other arguments, will be passed to the codebase’s script. Defaults to ().

gridsearch

mim.commands.gridsearch.gridsearch(package: str, config: str, gpus: int, gpus_per_node: int = None, cpus_per_task: int = 2, max_jobs: int = 1, partition: str = None, launcher: str = 'none', port: int = 29500, srun_args: Optional[str] = None, search_args: str = '', other_args: tuple = ()) → Tuple[bool, Union[str, Exception]][source]

Hyper parameter search with given config.

Parameters
  • package (str) – The codebase name.

  • config (str) – The config file path. If not exists, will search in the config files of the codebase.

  • gpus (int) – Number of gpus used for training.

  • gpus_per_node (int, optional) – Number of gpus per node to use (only applicable to launcher == “slurm”). Defaults to None.

  • cpus_per_task (int, optional) – Number of cpus per task to use (only applicable to launcher == “slurm”). Defaults to None.

  • partition (str, optional) – The partition name (only applicable to launcher == “slurm”). Defaults to None.

  • max_jobs (int, optional) – The max number of workers. Applicable only if launcher == ‘slurm’. Default to 1.

  • launcher (str, optional) – The launcher used to launch jobs. Defaults to ‘none’.

  • port (int, optional) – The port used for inter-process communication (only applicable to slurm / pytorch launchers). Default to 29500.

  • srun_args (str, optional) – Other srun arguments that might be used, all arguments should be in a string. Defaults to None.

  • search_args (str, optional) – Arguments for hyper parameters search, all arguments should be in a string. Defaults to None.

  • other_args (tuple, optional) – Other arguments, will be passed to the codebase’s training script. Defaults to ().