deprecate bidirectional_mapping util

This commit is contained in:
Cédric Deltheil 2023-09-07 18:18:19 +02:00 committed by Cédric Deltheil
parent 2786117469
commit c6fadd1c81

View file

@ -1,4 +1,4 @@
from typing import Dict, Iterable, Literal, TypeVar
from typing import Iterable, Literal, TypeVar
from PIL import Image
from numpy import array, float32
from pathlib import Path
@ -34,10 +34,6 @@ def interpolate(x: Tensor, factor: float | torch.Size, mode: str = "nearest") ->
) # type: ignore
def bidirectional_mapping(mapping: Dict[str, str]) -> Dict[str, str]:
return {**mapping, **{value: key for key, value in mapping.items()}}
def image_to_tensor(image: Image.Image, device: Device | str | None = None, dtype: DType | None = None) -> Tensor:
return torch.tensor(array(image).astype(float32).transpose(2, 0, 1) / 255.0, device=device, dtype=dtype).unsqueeze(
0