Skip to content

Commit 71aa846

Browse files
committed
fix memory leak
1 parent 07889e4 commit 71aa846

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

testSyncNet.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
parser.add_argument('--gpu_id', type=int, default='0', help='');
2424
parser.add_argument('--initial_model', type=str, default="data/syncnet.model", help='');
25-
parser.add_argument('--batch_size', type=int, default='50', help='');
25+
parser.add_argument('--batch_size', type=int, default='20', help='');
2626
parser.add_argument('--vshift', type=int, default='15', help='');
2727
parser.add_argument('--video', type=str, default="", help='');
2828

@@ -35,7 +35,7 @@ def calc_pdist(feat1, feat2, vshift=10):
3535

3636
win_size = vshift*2+1
3737

38-
feat2p = torch.nn.functional.pad(feat2,(0,0,vshift,vshift))
38+
feat2p = torch.nn.functional.pad(feat2,(0,0,vshift,vshift)).data
3939

4040
dists = []
4141

@@ -104,7 +104,8 @@ def evaluate(self, videopath, batch_size=50, vshift=10):
104104
# ========== ==========
105105

106106
if float(len(audio))/float(len(images)) != 640 :
107-
raw_input("Mismatch between the number of audio and video frames. Press ENTER to continue.")
107+
print("Mismatch between the number of audio and video frames. Type 'cont' to continue.")
108+
pdb.set_trace()
108109

109110
# ========== ==========
110111
# Generate video and audio feats
@@ -118,14 +119,14 @@ def evaluate(self, videopath, batch_size=50, vshift=10):
118119
for i in range(0,lastframe,batch_size):
119120

120121
im_batch = [ imtv[:,:,vframe:vframe+5,:,:] for vframe in range(i,min(lastframe,i+batch_size)) ]
121-
im_in = torch.cat(im_batch,0).cuda(self.__GPU_ID__)
122-
im_out = self.__S__.forward_lip(im_in);
123-
im_feat.append(im_out.cpu())
122+
im_in = torch.cat(im_batch,0)
123+
im_out = self.__S__.forward_lip(im_in.cuda(self.__GPU_ID__));
124+
im_feat.append(im_out.data.cpu())
124125

125126
cc_batch = [ cct[:,:,:,vframe*4:vframe*4+20] for vframe in range(i,min(lastframe,i+batch_size)) ]
126-
cc_in = torch.cat(cc_batch,0).cuda(self.__GPU_ID__)
127-
cc_out = self.__S__.forward_aud(cc_in)
128-
cc_feat.append(cc_out.cpu())
127+
cc_in = torch.cat(cc_batch,0)
128+
cc_out = self.__S__.forward_aud(cc_in.cuda(self.__GPU_ID__))
129+
cc_feat.append(cc_out.data.cpu())
129130

130131
im_feat = torch.cat(im_feat,0)
131132
cc_feat = torch.cat(cc_feat,0)

0 commit comments

Comments
 (0)