-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added evaluation code for MovieChat models
- Loading branch information
Showing
40 changed files
with
9,503 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import torch | ||
from omegaconf import OmegaConf | ||
|
||
# Source code | ||
from models.MovieChat.common.registry import registry | ||
from models.MovieChat.models.moviechat import MovieChat | ||
from models.MovieChat.models.moviechatplus import MovieChat as MovieChatPlus | ||
from models.MovieChat.conversation.conversation_video import Chat | ||
from models.MovieChat.processors.video_processor import AlproVideoEvalProcessor | ||
|
||
# Installed version | ||
# from MovieChat.processors.video_processor import AlproVideoEvalProcessor | ||
# from MovieChat.models.chat_model import Chat | ||
# from MovieChat.models.moviechat import MovieChat | ||
|
||
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') | ||
|
||
def load_model( | ||
config_path, *args, **kwargs | ||
): | ||
config = OmegaConf.load(config_path) | ||
|
||
model_class = { | ||
"moviechat" : MovieChat, | ||
"moviechat+" : MovieChatPlus | ||
}[config.model.arch] | ||
|
||
model = model_class.from_config(config.model).to(device) | ||
|
||
vis_processor_cfg = config.datasets.webvid.vis_processor.train | ||
vis_processor = AlproVideoEvalProcessor( | ||
image_size=vis_processor_cfg.image_size, | ||
n_frms=vis_processor_cfg.n_frms | ||
) | ||
|
||
text_processor = Chat(model=model, vis_processor=vis_processor, device=device) | ||
|
||
# For MovieChat, embed visual processor into text processor | ||
return model, None, text_processor |
Empty file.
Oops, something went wrong.