forked from prehistoric-systems/comixify
* Add keyframe model * Add segmentation utils * Add keyframes extraction pipeline * Add keyframe tests * Update dockerfile to include caffe * Add summe pretrained model * Add video for testing * Update keyframe pipeline, tests * Update settings to use in memory db for tests * Set keyframe number to 10, fix bugs * Fix keyframe order * Make requested changes * Fix Dockerfile * Make requested changes * Make requested changes * Add blank lines * Change dockerfile base cuda image to devel version * Add modified Cuda.cmake for Dockerfile * Add pyyaml dependecy to dockerfile * Update dockerfile * Update dockerfile * Fix markdown version error * Fix markdown version error * Change caffe installation to make * Update dockerfile * Update dockerfile * Fix boost imoprt * Fix boost not found bug * Add feature normalisation * Fix dateutil, fix caffe root slash * Fix slash bug * Add batching to feature extraction * Add model caching to keyframes extraction * Fix output images to be in proper range * Add time logging * Change feature batch to 128 * Change dockerfile * Fix dockerfile * Change feature batch to 10 * Add set mode gpu * Change feature batch to 64 * Change feature batch to 32 * Add I-frame frame sampling * Cleanup * Delete Cuda.cmake * Remove comments from Makefile.config * Cleanup * Fix color scheme switching * Remove cudnn.hpp, change caffe to 1.0 * Remove cudnn.hpp copy in dockerfile * Remove redundant run's in dockerfile * Change pretrained model
21 lines
735 B
Python
21 lines
735 B
Python
import torch.nn as nn
|
|
from torch.nn import functional as F
|
|
|
|
__all__ = ['DSN']
|
|
|
|
|
|
class DSN(nn.Module):
|
|
"""Deep Summarization Network"""
|
|
def __init__(self, in_dim=1024, hid_dim=256, num_layers=1, cell='lstm'):
|
|
super(DSN, self).__init__()
|
|
assert cell in ['lstm', 'gru'], "cell must be either 'lstm' or 'gru'"
|
|
if cell == 'lstm':
|
|
self.rnn = nn.LSTM(in_dim, hid_dim, num_layers=num_layers, bidirectional=True, batch_first=True)
|
|
else:
|
|
self.rnn = nn.GRU(in_dim, hid_dim, num_layers=num_layers, bidirectional=True, batch_first=True)
|
|
self.fc = nn.Linear(hid_dim*2, 1)
|
|
|
|
def forward(self, x):
|
|
h, _ = self.rnn(x)
|
|
p = F.sigmoid(self.fc(h))
|
|
return p
|