-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from ViCCo-Group/align_model
Kakaobrain Align model
- Loading branch information
Showing
6 changed files
with
50 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
"torchtyping", | ||
"tqdm", | ||
"CLIP", | ||
"transformers==4.40.1" | ||
# 'CLIP @ git+ssh://[email protected]/openai/[email protected]#egg=CLIP' # TODO: see issue #111 | ||
] | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Any | ||
from .custom import Custom | ||
from transformers import AlignModel, AutoProcessor | ||
|
||
|
||
class Kakaobrain_Align(Custom): | ||
def __init__(self, device, parameters) -> None: | ||
super().__init__(device) | ||
self.backend = "pt" | ||
|
||
def create_model(self) -> Any: | ||
model = AlignModel.from_pretrained("kakaobrain/align-base") | ||
processor = AutoProcessor.from_pretrained("kakaobrain/align-base") | ||
|
||
def preprocess_fn(images): | ||
out = processor(images=images, return_tensors="pt") | ||
return out['pixel_values'].squeeze(0) | ||
|
||
return model.vision_model, preprocess_fn |