Skip to content

Commit

Permalink
Add Sign Language detection model by Google
Browse files Browse the repository at this point in the history
  • Loading branch information
Prem-kumar27 committed Oct 23, 2021
1 parent 975b088 commit 30cb9a1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions openhands/models/detection/lstm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import torch
import torch.nn as nn

# Paper: https://arxiv.org/abs/2008.04637
# Models ported from: https://github.com/google-research/google-research/tree/master/sign_language_detection

class SignDetectionLSTM(nn.Module):
def __init__(self, input_dim=25, input_dropout = 0.5, encoder_layers = 1, hidden_size = 2**6, encoder_bidirectional = False):
super(SignDetectionLSTM, self).__init__()
self.input_dropout = nn.Dropout(p=input_dropout)
self.lstm = nn.LSTM(input_dim, hidden_size, encoder_layers, bidirectional=encoder_bidirectional, batch_first=True)
self.linear = nn.Linear(hidden_size, 2)

def forward(self, x, hidden=None):
# input.shape = [batch_size, seq_length, input_dim]
x = self.input_dropout(x)
lstm_out, self.hidden = self.lstm(input, hidden)
# shape = [batch_size, out_dim]
y_pred = self.linear(self.dropout(lstm_out[:,-1,:]))
return y_pred

0 comments on commit 30cb9a1

Please sign in to comment.