Exemplo n.º 1
0
    def __getitem__(self, idx):

        textprocessor = TextProcessor(VOCAB_SIZE=self.VOCAB_SIZE)
        utils = Utils()

        video_file = self.train_dir_list[
            idx]  # get video file corresponding to the id, idx

        output_text = self.utils.output_text(
            self.train_corpus,
            video_file)  # get the text contained in the video file

        #### generate input 2,  from the output_text
        sentence_to_index = textprocessor.sentence_to_indices(
            utils.tagger_input(utils.clean_text(output_text)),
            self.word_to_index)
        X_2 = textprocessor.get_output(sentence_to_index, self.NUMBER_OF_WORDS)

        #### generate output,  from the output_text
        sentence_to_index = textprocessor.sentence_to_indices(
            utils.tagger_output(utils.clean_text(output_text)),
            self.word_to_index)
        y = textprocessor.get_output(sentence_to_index, self.NUMBER_OF_WORDS)

        video_path = self.train_dir + video_file

        # generate input 1
        X_1 = utils.video_to_frames(video_path, self.number_of_frames,
                                    self.device, self.INPUT_SIZE, self.model,
                                    self.transform)
        #X_1 = pre_data[idx]
        return (X_1, torch.tensor(X_2)), torch.tensor(y)