| 409 | |
| 410 | |
| 411 | class FanEncoder(ModelMixin, ConfigMixin, FromOriginalModelMixin): |
| 412 | def __init__(self, pose_dim=6, eye_dim=6): |
| 413 | super(FanEncoder, self).__init__() |
| 414 | self.model = FAN_use() |
| 415 | |
| 416 | self.to_mouth = nn.Sequential( |
| 417 | nn.Linear(512, 512), nn.ReLU(), nn.BatchNorm1d(512), nn.Linear(512, 512) |
| 418 | ) |
| 419 | self.mouth_embed = nn.Sequential( |
| 420 | nn.ReLU(), nn.Linear(512, 512 - pose_dim - eye_dim) |
| 421 | ) |
| 422 | |
| 423 | self.to_headpose = nn.Sequential( |
| 424 | nn.Linear(512, 512), nn.ReLU(), nn.BatchNorm1d(512), nn.Linear(512, 512) |
| 425 | ) |
| 426 | self.headpose_embed = nn.Sequential(nn.ReLU(), nn.Linear(512, pose_dim)) |
| 427 | |
| 428 | self.to_eye = nn.Sequential( |
| 429 | nn.Linear(512, 512), nn.ReLU(), nn.BatchNorm1d(512), nn.Linear(512, 512) |
| 430 | ) |
| 431 | self.eye_embed = nn.Sequential(nn.ReLU(), nn.Linear(512, eye_dim)) |
| 432 | |
| 433 | self.to_emo = nn.Sequential( |
| 434 | nn.Linear(512, 512), nn.ReLU(), nn.BatchNorm1d(512), nn.Linear(512, 512) |
| 435 | ) |
| 436 | self.emo_embed = nn.Sequential(nn.ReLU(), nn.Linear(512, 30)) |
| 437 | |
| 438 | def forward_feature(self, x): |
| 439 | net = self.model(x) |
| 440 | return net |
| 441 | |
| 442 | def forward(self, x): |
| 443 | x = self.model(x) |
| 444 | mouth_feat = self.to_mouth(x) |
| 445 | headpose_feat = self.to_headpose(x) |
| 446 | headpose_emb = self.headpose_embed(headpose_feat) |
| 447 | eye_feat = self.to_eye(x) |
| 448 | eye_embed = self.eye_embed(eye_feat) |
| 449 | emo_feat = self.to_emo(x) |
| 450 | emo_embed = self.emo_embed(emo_feat) |
| 451 | |
| 452 | return headpose_emb, eye_embed, emo_embed, mouth_feat |
no outgoing calls
no test coverage detected