monailabel.utils.others.generic module

monailabel.utils.others.generic.create_dataset_from_path(folder, image_dir='images', label_dir='labels', img_ext='.jpg', lab_ext='.png')[source]
monailabel.utils.others.generic.device_list()[source]
monailabel.utils.others.generic.device_map()[source]
monailabel.utils.others.generic.download_file(url, path, delay=1, skip_on_exists=True)[source]
monailabel.utils.others.generic.file_checksum(file, algo='SHA256')[source]
monailabel.utils.others.generic.file_ext(name)[source]
Return type

str

monailabel.utils.others.generic.get_basename(path)[source]

Gets the basename of a file.

Ref: https://stackoverflow.com/questions/8384737/extract-file-name-from-path-no-matter-what-the-os-path-format

monailabel.utils.others.generic.get_basename_no_ext(path)[source]
monailabel.utils.others.generic.get_bundle_models(app_dir, conf, conf_key='models')[source]

The funtion to get bundle models either from available model zoo or local files. MONAI Label maintains a list of supported bundles, non-labeling bundles are not supported. This function will filter available bundles according to the maintaining list.

Parameters
  • app_dir – the app directory path

  • conf – configs of start_server command

  • conf_key – default to “models” for monaibundle app, if radiology app wants to use bundle models, “–conf bundles <names>” is used.

Returns

a dictionary that contains the available bundles.

Example

Bundle name: spleen_ct_segmentation, this will use latest version of the bundle. BUndle name with specific version: spleen_ct_segmentation_v0.4.0, this will download the specified version.

monailabel.utils.others.generic.get_mime_type(file)[source]
monailabel.utils.others.generic.get_zoo_bundle(model_dir, conf, models, conf_key)[source]
monailabel.utils.others.generic.gpu_count()[source]
monailabel.utils.others.generic.gpu_memory_map()[source]

Get the current gpu usage.

Returns

usage – Keys are device ids as integers. Values are memory usage as integers in MB.

Return type

dict

monailabel.utils.others.generic.handle_torch_linalg_multithread(req)[source]
monailabel.utils.others.generic.init_log_config(log_config, app_dir, log_file, root_level=None)[source]
monailabel.utils.others.generic.is_openslide_supported(name)[source]
monailabel.utils.others.generic.md5_digest(s)[source]
Return type

str

monailabel.utils.others.generic.name_to_device(device)[source]
monailabel.utils.others.generic.path_to_uri(path)[source]
Return type

str

monailabel.utils.others.generic.remove_file(path)[source]
Return type

None

monailabel.utils.others.generic.run_command(command, args=None, plogger=None)[source]
monailabel.utils.others.generic.strtobool(str)[source]