-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbase.py
40 lines (24 loc) · 936 Bytes
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import torch
import logging
from torch import nn
from .FusionNets import multimodal_methods_map
__all__ = ['ModelManager']
# base backbones
class MIA(nn.Module):
def __init__(self, args):
super(MIA, self).__init__()
fusion_method = multimodal_methods_map[args.multimodal_method]
self.model = fusion_method(args)
def forward(self, text_feats, video_data, audio_data, *args, **kwargs):
mm_model = self.model(text_feats, video_data, audio_data, *args, **kwargs)
return mm_model
def vim(self):
return self.model.vim()
class ModelManager:
def __init__(self, args):
self.logger = logging.getLogger(args.logger_name)
self.device = args.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
def _set_model(self, args):
model = MIA(args)
model.to(self.device)
return model