SDK Core ML Utils API

Miscellaneous operations in Pytorch

metavision_core_ml.utils.torch_ops.cuda_tick()

Measures time for torch operations on gpu.

metavision_core_ml.utils.torch_ops.cuda_time(func)

Decorator for Pytorch ops on gpu.

Parameters

func – method to time

metavision_core_ml.utils.torch_ops.normalize_tiles(tensor, num_stds=6, num_dims=2, real_min_max=True)

Normalizes tiles, allows us to have normalized views (we filter outliers + standardize)

Parameters

tensor – tensor input, we assume last 2 dims are H,W

Returns

normalized tensor

Return type

tensor

metavision_core_ml.utils.torch_ops.viz_flow(flow)

Visualizes flow in rgb colors

Parameters

flow – (B,2,H,W) tensor

Returns

(B,3,H,W) tensor

Return type

rgb

Tools common to training main functions.

metavision_core_ml.utils.train_utils.search_latest_checkpoint(root_dir, mode='time')

looks for latest checkpoint in latest sub-directory

A collection of utilities for searching image/video files.

metavision_core_ml.utils.files.grab_files(adir, extensions, recursive=True)

Grabs files with allowed extensions

Parameters
  • adir (str) – directory

  • extensions (list) – allowed extensions

  • recursive (boolean) – search recursively

Returns

files

metavision_core_ml.utils.files.grab_h5s(adir, recursive=True)

Grabs h5 files

Parameters
  • adir – directory with h5 files

  • recursive (boolean) – search recursively

Returns

h5 files

Return type

files

metavision_core_ml.utils.files.grab_images(adir, recursive=True)

Grabs image files

Parameters

adir – directory with images

Returns

image files

Return type

files

metavision_core_ml.utils.files.grab_images_and_videos(adir, recursive=True)

Grabs image and video files

Parameters

adir – directory with images

Returns

image and video files

Return type

files

metavision_core_ml.utils.files.grab_jsons(adir, recursive=True)

Grabs json files

Parameters
  • adir – directory with json files

  • recursive (boolean) – search recursively

Returns

json files

Return type

files

metavision_core_ml.utils.files.grab_tiff_images(adir, recursive=True)

Grabs tiff image files

Parameters

adir – directory with tiff images

Returns

image files

Return type

files

metavision_core_ml.utils.files.grab_videos(adir, recursive=True)

Grabs videos in a directory

Parameters
  • adir (str) – directory

  • recursive (boolean) – search recursively

Returns

files with image/ video extension

Return type

files

metavision_core_ml.utils.files.is_image(path)

Checks if a path is an image

Parameters

path – file path

Returns

True or False

Return type

is_image (bool)

metavision_core_ml.utils.files.is_tiff_image(path)

Checks if a path is a tiff image

Parameters

path – file path

Returns

True or False

Return type

is_image (bool)

metavision_core_ml.utils.files.is_video(path)

Checks if a path is a video

Parameters

path – file path

Returns

True or False

Return type

is_video (bool)

This wrapper shows and/or writes a video

class metavision_core_ml.utils.show_or_write.ShowWrite(window_name, video_path, crf=30)

ShowWrite either shows and/or writes a video

Parameters
  • window_name (str) – if empty, will not show

  • video_path (str) – if empty, will not write

  • crf (int) – compression factor for video output