-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIQAmodel.py
43 lines (35 loc) · 1.2 KB
/
IQAmodel.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
41
42
43
import torch
import torch.nn as nn
class IQAMLPModel(nn.Module):
def __init__(self, cfg):
super(IQAMLPModel, self).__init__()
input_dim = cfg['input_dim']
hidden_dim = cfg['hidden_dim']
output_dim = cfg['output_dim']
self.mlp = nn.Sequential(
nn.Linear(input_dim, hidden_dim),
nn.ReLU(),
nn.Linear(hidden_dim, hidden_dim),
nn.ReLU(),
nn.Linear(hidden_dim, output_dim)
)
def forward(self, image_features, text_features):
features = torch.cat((image_features, text_features), dim=1)
output = self.mlp(features)
return output
class IQADecoderModel(nn.Module):
def __init__(self, cfg):
super(IQADecoderModel, self).__init__()
self.decoder = nn.Sequential(
nn.Linear(1024, 256),
nn.ReLU(),
nn.Linear(256, 64),
nn.ReLU(),
nn.Linear(64, 16),
nn.ReLU(),
nn.Linear(16, 1)
)
def forward(self, image_features, text_features):
features = torch.cat((image_features, text_features), dim=1)
output = self.decoder(features)
return output