mirror of
https://github.com/finegrain-ai/refiners.git
synced 2024-11-22 06:08:46 +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 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
|
||||
|
|
Loading…
Reference in a new issue