Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions SyncNetInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from scipy.io import wavfile
from SyncNetModel import *

cuda = False

# ==================== Get OFFSET ====================

Expand Down Expand Up @@ -101,12 +102,18 @@ def evaluate(self, opt, videofile):

im_batch = [ imtv[:,:,vframe:vframe+5,:,:] for vframe in range(i,min(lastframe,i+opt.batch_size)) ]
im_in = torch.cat(im_batch,0)
im_out = self.__S__.forward_lip(im_in.cuda());
if cuda:
im_out = self.__S__.forward_lip(im_in.cuda());
else:
im_out = self.__S__.forward_lip(im_in);
im_feat.append(im_out.data.cpu())

cc_batch = [ cct[:,:,:,vframe*4:vframe*4+20] for vframe in range(i,min(lastframe,i+opt.batch_size)) ]
cc_in = torch.cat(cc_batch,0)
cc_out = self.__S__.forward_aud(cc_in.cuda())
if cuda:
cc_out = self.__S__.forward_aud(cc_in.cuda())
else:
cc_out = self.__S__.forward_aud(cc_in)
cc_feat.append(cc_out.data.cpu())

im_feat = torch.cat(im_feat,0)
Expand Down
14 changes: 8 additions & 6 deletions SyncNetModel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import torch
import torch.nn as nn

cuda = False

def save(model, filename):
with open(filename, "wb") as f:
torch.save(model, f);
Expand Down Expand Up @@ -90,11 +92,11 @@ def __init__(self, num_layers_in_fc_layers = 1024):
nn.ReLU(inplace=True),
);

self.netcnnaud = self.netcnnaud.cuda();
self.netcnnlip = self.netcnnlip.cuda();
self.netfcaud = self.netfcaud.cuda();
self.netfclip = self.netfclip.cuda();

if cuda:
self.netcnnaud = self.netcnnaud.cuda();
self.netcnnlip = self.netcnnlip.cuda();
self.netfcaud = self.netfcaud.cuda();
self.netfclip = self.netfclip.cuda();

def forward_aud(self, x):

Expand All @@ -110,4 +112,4 @@ def forward_lip(self, x):
mid = mid.view((mid.size()[0], -1)); # N x (ch x 24)
out = self.netfclip(mid);

return out;
return out;
2 changes: 1 addition & 1 deletion run_syncnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

# ==================== GET OFFSETS ====================

with open(os.path.join(opt.work_dir,opt.reference,'tracks.pckl'), 'r') as fil:
with open(os.path.join(opt.work_dir,opt.reference,'tracks.pckl'), 'rb') as fil:
tracks = pickle.load(fil)

dists = []
Expand Down