🌟 API#
This part of the documentation covers all the interfaces of scivision.
- scivision.io.reader.load_data_from_plugin(config: dict, branch: str = 'main') Dataset #
Load a dataset from a data plugin (python package).
- Parameters:
config (dict) – The loaded data.yml config.
branch (str, default = main) – Specify the name of a github branch if loading from github.
- Returns:
The dataset to be visualised, loaded via xarray.
- Return type:
xarray.Dataset
- scivision.io.reader.load_dataset(path: PathLike, branch: str = 'main') YAMLFileCatalog #
Load a dataset.
- Parameters:
path (PathLike) – The filename, path or URL of an intake catalog, which links to a dataset.
branch (str, default = main) – Specify the name of a github branch if loading from github.
- Returns:
An intake catalog object representing the loaded dataset (see intake.readthedocs).
- Return type:
intake.catalog.local.YAMLFileCatalog
- scivision.io.reader.load_pretrained_model(path: PathLike, branch: str = 'main', allow_install: bool = False, model_selection: str = 'default', load_multiple: bool = False, *args, **kwargs) PretrainedModel #
Load a pre-trained model.
- Parameters:
path (PathLike) – The filename, path or URL of a pretrained model description.
branch (str, default = main) – Specify the name of a github branch if loading from github.
allow_install (bool, default = False) – Allow installation of remote package via pip.
model_selection (str, default = default) – Specify the name of the model if there is > 1 in the model repo package.
load_multiple (bool, default = False) – Modifies the return to be a list of scivision.PretrainedModel’s.
- Returns:
pretrained_model – The instantiated pre-trained model.
- Return type:
scivision.PretrainedModel
- class scivision.catalog.catalog.PandasCatalog(datasources=None, models=None, projects=None)#
- compatible_datasources(model) PandasQueryResult #
Return all datasources that are compatible with model
- Parameters:
model (str or dict-like) – Any dictionary-like (including CatalogModelEntry) that has keys ‘format’, ‘tasks’ and ‘labels_required’, representing these properties of the model. If a string is passed, this is used to look up the model (in self._models).
- Returns:
result – A QueryResult instance containing the datasources compatible with the given model (convertible to a dict or pd.DataFrame).
- Return type:
QueryResult
- compatible_models(datasource) PandasQueryResult #
Return all models that are compatible with datasource
- Parameters:
datasource (str or dict-like) – Any dictionary-like (including CatalogDatasourceEntry) that has keys ‘format’, ‘tasks’ and ‘labels_provided’, representing these properties of the datasource. If a string is passed, this is used to look up the datasource (in self._datasources).
- Returns:
result – A QueryResult instance containing the models compatible with the given datasource (convertible to a dict or pd.DataFrame).
- Return type:
QueryResult
- validate()#
Extra validation
Raise ValueError if projects refer to nonexistent models or datasources
- class scivision.vis.display.display_objects(image: ndarray, predictions: list, label_nums: bool = False)#
Display an image with colored bounding boxes for objects identified by a scivision object detection model.
- Parameters:
image (np.ndarray) – A numpy ndarray representation of an image.
predictions (list) – A list of dictionaries, on for each detected object containing ‘score’, ‘label’ and ‘box’ keys. ‘score’ should be a float between 0 and 1. ‘label’ should be a string that labels the object. ‘box’ should be a dict with ‘xmin’, ‘ymin’, ‘xmax’ and ‘ymax’ keys, which denote the boundaries of each box (detected object).
label_nums (bool = False) – When True, bounding boxes are numbered in addition to being colored.
- Returns:
The input image with colored bounding boxes and an accompanying pandas
dataframe legend showing corresponding labels and scores for each object.