()
return cropped_clip
Gets a clip from the train dataset, cropped randomly to c.TRAIN_HEIGHT x c.TRAIN_WIDTH.

    @return: An array of shape [c.TRAIN_HEIGHT, c.TRAIN_WIDTH, (3 * (c.HIST_LEN + 1))].
             A frame sequence with values normalized in range [-1, 1].
Gets a clip from the train dataset, cropped randomly to c.TRAIN_HEIGHT x c.TRAIN_WIDTH.
Gets a clip from the train dataset cropped randomly to c . TRAIN_HEIGHT x c . TRAIN_WIDTH .
def process_clip():
    """
    Gets a clip from the train dataset, cropped randomly to c.TRAIN_HEIGHT x c.TRAIN_WIDTH.

    @return: An array of shape [c.TRAIN_HEIGHT, c.TRAIN_WIDTH, (3 * (c.HIST_LEN + 1))].
             A frame sequence with values normalized in range [-1, 1].
    """
    clip = get_full_clips(c.TRAIN_DIR, 1)[0]

    # Randomly crop the clip. With 0.05 probability, take the first crop offered, otherwise,
    # repeat until we have a clip with movement in it.
    take_first = np.random.choice(2, p=[0.95, 0.05])
    cropped_clip = np.empty([c.TRAIN_HEIGHT, c.TRAIN_WIDTH, 3 * (c.HIST_LEN + 1)])
    for i in xrange(100):  # cap at 100 trials in case the clip has no movement anywhere
        crop_x = np.random.choice(c.FULL_WIDTH - c.TRAIN_WIDTH + 1)
        crop_y = np.random.choice(c.FULL_HEIGHT - c.TRAIN_HEIGHT + 1)
        cropped_clip = clip[crop_y:crop_y + c.TRAIN_HEIGHT, crop_x:crop_x + c.TRAIN_WIDTH, :]

        if take_first or clip_l2_diff(cropped_clip) > c.MOVEMENT_THRESHOLD:
            break

    return cropped_clip
def process_clip ( ) : clip = get_full_clips ( c . TRAIN_DIR , 1 ) [ 0 ] # Randomly crop the clip. With 0.05 probability, take the first crop offered, otherwise, # repeat until we have a clip with movement in it. take_first = np . random . choice ( 2 , p = [ 0.95 , 0.05 ] ) cropped_clip = np . empty ( [ c . TRAIN_HEIGHT , c . TRAIN_WIDTH , 3 * ( c . HIST_LEN + 1 ) ] ) for i in xrange ( 100 ) : # cap at 100 trials in case the clip has no movement anywhere crop_x = np . random . choice ( c . FULL_WIDTH - c . TRAIN_WIDTH + 1 ) crop_y = np . random . choice ( c . FULL_HEIGHT - c . TRAIN_HEIGHT + 1 ) cropped_clip = clip [ crop_y : crop_y + c . TRAIN_HEIGHT , crop_x : crop_x + c . TRAIN_WIDTH , : ] if take_first or clip_l2_diff ( cropped_clip ) > c . MOVEMENT_THRESHOLD : break return cropped_clip