Beispiel #1
0
    def _fill_names_sequences(self):
        '''Fill list of sequences [[(prefix1, name), (prefix1, name1), ..], ..]

        Fill `names_sequences` with lists of sequences, i.e., of lists
        of (prefix, name) pair with the desired overlap and seq_length N:
            [(prefix1, name1), (prefix1, name2), .., (prefix1, nameN)]
            [(prefix1, name(N-overlap), (prefix1, name(N-overlap+1)), ..,
             (prefix1, name(N-overlap+N)]
        '''
        names_sequences = {}
        seq_length = max(self.seq_length, 1)

        # Cycle over prefix/subset/video/category/...
        for prefix, names in self.names_per_subset.items():
            # Repeat the first and last elements so that the first and last
            # sequences are filled with repeated elements up/from the
            # middle element.
            if self.return_extended_sequences:
                names = ([names[0]] * (seq_length // 2) + names + [names[-1]] *
                         (seq_length // 2))
            # Fill sequences with multiple el with form
            # [(prefix, name1), (prefix, name2), ...]. The names here
            # have overlap = (seq_length - 1), i.e., "stride" = 1
            sequences = [
                el for el in overlap_grouper(names, seq_length, prefix=prefix)
            ]
            # Sequences of frames with the requested overlap
            sequences = sequences[::seq_length - self.overlap]

            names_sequences[prefix] = sequences
        self.names_sequences = names_sequences
    def _fill_names_sequences(self):
        '''Fill list of sequences [[(prefix1, name), (prefix1, name1), ..], ..]

        Fill `names_sequences` with lists of sequences, i.e., of lists
        of (prefix, name) pair with the desired overlap and seq_length N:
            [(prefix1, name1), (prefix1, name2), .., (prefix1, nameN)]
            [(prefix1, name(N-overlap), (prefix1, name(N-overlap+1)), ..,
             (prefix1, name(N-overlap+N)]
        '''
        names_sequences = {}
        seq_length = max(self.seq_length, 1)

        # Cycle over prefix/subset/video/category/...
        for prefix, names in self.names_per_subset.items():
            # Repeat the first and last elements so that the first and last
            # sequences are filled with repeated elements up/from the
            # middle element.
            if self.return_extended_sequences:
                names = ([names[0]] * (seq_length // 2) + names +
                         [names[-1]] * (seq_length // 2))
            # Fill sequences with multiple el with form
            # [(prefix, name1), (prefix, name2), ...]. The names here
            # have overlap = (seq_length - 1), i.e., "stride" = 1
            sequences = [el for el in overlap_grouper(
                names, seq_length, prefix=prefix)]
            # Sequences of frames with the requested overlap
            sequences = sequences[::seq_length - self.overlap]

            names_sequences[prefix] = sequences
        self.names_sequences = names_sequences