pike-vibe / src /__init__.py
naboosie's picture
pike vibe app
1d58ba1
Raw
History Blame Contribute Delete
803 Bytes
import torch
import torch.nn as nn
from transformers import ViTMAEModel
class VibeMAE(nn.Module):
def __init__(self):
super().__init__()
# This is the pre-trained brain from Facebook
self.mae = ViTMAEModel.from_pretrained("facebook/vit-mae-base")
# This is the "Vibe Head" that calculates the 3 scores
self.vibe_head = nn.Sequential(
nn.Linear(768, 256),
nn.ReLU(),
nn.Linear(256, 3), # Outputs: Ferd, Aura, Munch
nn.Sigmoid() # Keeps scores between 0 and 1
)
def forward(self, x):
outputs = self.mae(x)
# We take the [CLS] token which represents the "vibe" of the whole face
latent = outputs.last_hidden_state[:, 0, :]
return self.vibe_head(latent)