-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mainline' into yihan/openapi-specs
- Loading branch information
Showing
12 changed files
with
538 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
from pydantic import BaseModel | ||
from torchvision.transforms import Compose | ||
from typing import Optional | ||
from typing import Optional, Any | ||
|
||
from marqo.base_model import MarqoBaseModel | ||
from marqo.s2_inference.multimodal_model_load import Modality | ||
|
||
class Preprocessors(BaseModel): | ||
image: Optional[Compose] = None | ||
text: Optional[Compose] = None | ||
video: Optional[Compose] = None | ||
audio: Optional[Compose] = None | ||
|
||
class Config: | ||
arbitrary_types_allowed = True | ||
class Preprocessors(MarqoBaseModel): | ||
"""The type of preprocessors is unknown, so we use Any.""" | ||
image: Optional[Any] = None | ||
text: Optional[Any] = None | ||
video: Optional[Any] = None | ||
audio: Optional[Any] = None | ||
|
||
def get_preprocessor(self, modality: Modality): | ||
if modality == Modality.IMAGE: | ||
return self.image | ||
elif modality == Modality.TEXT: | ||
return self.text | ||
elif modality == Modality.VIDEO: | ||
return self.video | ||
elif modality == Modality.AUDIO: | ||
return self.audio | ||
else: | ||
raise ValueError(f"Unknown modality {modality}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.