mirror of
https://github.com/finegrain-ai/refiners.git
synced 2024-11-09 23:12:02 +00:00
deprecate bidirectional_mapping util
This commit is contained in:
parent
2786117469
commit
c6fadd1c81
|
@ -1,4 +1,4 @@
|
||||||
from typing import Dict, Iterable, Literal, TypeVar
|
from typing import Iterable, Literal, TypeVar
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from numpy import array, float32
|
from numpy import array, float32
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -34,10 +34,6 @@ def interpolate(x: Tensor, factor: float | torch.Size, mode: str = "nearest") ->
|
||||||
) # type: ignore
|
) # 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:
|
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(
|
return torch.tensor(array(image).astype(float32).transpose(2, 0, 1) / 255.0, device=device, dtype=dtype).unsqueeze(
|
||||||
0
|
0
|
||||||
|
|
Loading…
Reference in a new issue