Skip to content

Commit fe2c87b

Browse files
Fixed multimodal interface types so that they work with 3.9
1 parent 3269ed3 commit fe2c87b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

turftopic/encoders/multimodal.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from typing import Protocol
22

33
from PIL import Image
4-
from torch import Tensor
5-
from torch.utils.data import DataLoader
64

75

86
class MultimodalEncoder(Protocol):
@@ -14,20 +12,20 @@ def get_text_embeddings(
1412
*,
1513
batch_size: int = 8,
1614
**kwargs,
17-
) -> Tensor: ...
15+
): ...
1816

1917
def get_image_embeddings(
2018
self,
21-
images: list[Image.Image] | DataLoader,
19+
images: list[Image.Image],
2220
*,
2321
batch_size: int = 8,
2422
**kwargs,
25-
) -> Tensor: ...
23+
): ...
2624

2725
def get_fused_embeddings(
2826
self,
2927
texts: list[str] = None,
3028
images: list[Image.Image] = None,
3129
batch_size: int = 8,
3230
**kwargs,
33-
) -> Tensor: ...
31+
): ...

turftopic/multimodal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from __future__ import annotations
22

33
from abc import abstractmethod
4-
from typing import Iterable, Optional, TypedDict
4+
from typing import Iterable, Optional, TypedDict, Union
55

66
import numpy as np
77
from PIL import Image
88

99
UrlStr = str
1010

11-
ImageRepr = [Image.Image | UrlStr]
11+
ImageRepr = Union[Image.Image, UrlStr]
1212

1313

1414
def _load_images(images: Iterable[ImageRepr]) -> Iterable[Image]:

0 commit comments

Comments
 (0)