from ml import logging try: from PIL import * except Exception as e: logging.warn("pillow unavailable, run `mamba install pillow` to install")
# - GTX Titan X # SM61 or SM_61, compute_61 # – GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, # - Titan Xp, Tesla P40, Tesla P4, # - Discrete GPU on the NVIDIA Drive PX2 # SM70 or SM_70, compute_70 # - Titan V # SM75 or SM_75, compute_75 # – GTX/RTX Turing # – GTX 1660 Ti, RTX 2060, RTX 2070, RTX 2080, # - Titan RTX, if not os.environ.get('TORCH_CUDA_ARCH_LIST'): # os.environ['TORCH_CUDA_ARCH_LIST'] = '5.2;6.1;7.0;7.5;8.0;8.6+PTX' logging.warn( f'TORCH_CUDA_ARCH_LIST not set, build based on local GPU capability={torch.cuda.get_device_capability(0)}' ) cwd = Path(__file__).parent pkg = sh('basename -s .git `git config --get remote.origin.url`').lower() PKG = pkg.upper() def write_version_py(path, major=None, minor=None, patch=None, suffix='', sha='Unknown'): if major is None or minor is None or patch is None: major, minor, patch = sh("git describe --abbrev=0 --tags")[1:].split(
from typing import Union from ml import logging try: from ml.vision.io import * except Exception as e: logging.warn(f"{e}, ml.vision.io unavailable, run `mamba install ml-vision -c NECLA-ML` to install") else: from pathlib import Path from ml.vision import io import torch as th def load(path: Union[str, Path], *args): r"""Load a file in supported image or video formats. Other args and kwargs from APIs to support: - read_image(path: str, mode: torchvision.io.image.ImageReadMode = <ImageReadMode.UNCHANGED: 0>) → torch.Tensor - read_video(filename: str, start_pts: int = 0, end_pts: Optional[float] = None, pts_unit: str = "pts") -> Tuple[torch.Tensor, torch.Tensor, Dict[str, Any]] """ suffix = Path(path).suffix.lower() if suffix in ['.png', '.jpg', '.jpeg']: return io.read_image(str(path), *args) else: # Tuple[torch.Tensor, torch.Tensor, Dict[str, Any]] return io.read_video(str(path), *args) def save(data: th.Tensor, path: Union[str, Path], *args, **kwargs): """Encode image to save in jpeg or png. Args: data (PIL.Image, accimage.Image, Tensor[C, H, W, dtype=uint8] or Tensor[T, H, W, C, dtype=uint8]))
from ml import logging try: from av import * except Exception as e: logging.warn("PyAV unavailable, run `mamba install av -c conda-forge` to install")
from ml import logging try: from cv2 import * except Exception as e: logging.warn( "opencv unavailable, run `mamba install opencv -c conda-forge` to install" )