Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
Merge pull request #285 from gnes-ai/fix-memory
Browse files Browse the repository at this point in the history
fix(memory_leak): try to fix memory leak
  • Loading branch information
mergify[bot] authored Sep 24, 2019
2 parents fede29c + 7108460 commit 148f096
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions gnes/preprocessor/io_utils/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ def encode_video(images: 'np.ndarray',
err = '\n'.join([' '.join(cmd_args), err.decode('utf8')])
raise IOError(err)

if proc.stdout is not None:
proc.stdout.close()
if proc.stderr is not None:
proc.stderr.close()

return output


Expand Down
4 changes: 2 additions & 2 deletions gnes/preprocessor/video/shotdetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def detect_shots(self, frames: 'np.ndarray') -> List[List['np.ndarray']]:

shots = []
for ci in range(0, len(shot_bounds) - 1):
shots.append(frames[shot_bounds[ci]:shot_bounds[ci + 1]])
shots.append(frames[shot_bounds[ci]:shot_bounds[ci + 1]].copy())

return shots

Expand All @@ -87,7 +87,7 @@ def apply(self, doc: 'gnes_pb2.Document') -> None:
elif raw_type == gnes_pb2.NdArray:
video_frames = blob2array(doc.raw_video)
if self.vframes > 0:
video_frames = video_frames[0:self.vframes, :]
video_frames = video_frames[0:self.vframes, :].copy()

num_frames = len(video_frames)
if num_frames > 0:
Expand Down

0 comments on commit 148f096

Please sign in to comment.