Skip to content

Commit

Permalink
Update frameselectiontools.py
Browse files Browse the repository at this point in the history
Hello! np.random.randint samples with replacement, which I think will not be ideal to keep a diverse training set in an edge case where numframestopick is of the order of number of frames in the video.
  • Loading branch information
kanishkbjain authored Aug 13, 2018
1 parent 4061fdd commit 723174e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Generating_a_Training_Set/frameselectiontools.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def UniformFrames(clip,numframes2pick,start,stop,Index="all"):
print("Uniformly extracting of frames from", start*clip.duration," seconds to", stop*clip.duration, " seconds.")
if Index=="all":
if start==0:
frames2pick = np.random.randint(math.ceil(clip.duration * clip.fps * stop), size=numframes2pick - 1)
frames2pick = np.random.choice(math.ceil(clip.duration * clip.fps * stop), size=numframes2pick - 1, replace = False)
else:
frames2pick = np.random.randint(low=math.floor(start*clip.duration * clip.fps),high=math.ceil(clip.duration * clip.fps * stop), size=numframes2pick - 1)
frames2pick = np.random.choice(range(math.floor(start*clip.duration * clip.fps),math.ceil(clip.duration * clip.fps * stop)), size=numframes2pick - 1, replace = False)
return frames2pick
else:
startindex=int(np.floor(clip.fps*clip.duration*start))
Expand Down

0 comments on commit 723174e

Please sign in to comment.