Beispiel #1
0
    def _get_metainfo(self, index):
        question = gdef.translate_question(self.questions[index])
        scene = gdef.translate_scene(self.scenes[question['image_index']])
        question['scene'] = scene

        question['image_index'] = question['image_index']
        question['image_filename'] = gdef.get_image_filename(scene)
        question['question_index'] = index
        question['question_tokenized'] = nltk.word_tokenize(question['question'])

        # program section
        has_program = False
        if 'program_nsclseq' in question:
            question['program_raw'] = question['program_nsclseq']
            question['program_seq'] = question['program_nsclseq']
            has_program = True
        elif 'program' in question:
            question['program_raw'] = question['program']
            question['program_seq'] = gdef.program_to_nsclseq(question['program'], question)
            has_program = True

        if has_program:
            question['program_tree'] = nsclseq_to_nscltree(question['program_seq'])
            question['program_qsseq'] = nsclseq_to_nsclqsseq(question['program_seq'])
            question['program_qstree'] = nscltree_to_nsclqstree(question['program_tree'])
            question['question_type'] = question['program_seq'][-1]['op']
        else:
            question['question_type'] = None

        return question
Beispiel #2
0
    def _get_metainfo(self, index):
        question = gdef.translate_question(self.questions[index])
        scene = gdef.translate_scene(self.scenes[question["image_index"]])
        question["scene"] = scene

        question["image_index"] = question["image_index"]
        question["image_filename"] = gdef.get_image_filename(scene)
        question["question_index"] = index
        question["question_tokenized"] = nltk.word_tokenize(question["question"])

        # program section
        has_program = False
        if "program_nsclseq" in question:
            question["program_raw"] = question["program_nsclseq"]
            question["program_seq"] = question["program_nsclseq"]
            has_program = True
        elif "program" in question:
            question["program_raw"] = question["program"]
            question["program_seq"] = gdef.program_to_nsclseq(
                question["program"], question
            )
            has_program = True

        if has_program:
            question["program_tree"] = nsclseq_to_nscltree(question["program_seq"])
            question["program_qsseq"] = nsclseq_to_nsclqsseq(question["program_seq"])
            question["program_qstree"] = nscltree_to_nsclqstree(
                question["program_tree"]
            )
            question["question_type"] = question["program_seq"][-1]["op"]
        else:
            question["question_type"] = None

        return question
Beispiel #3
0
    def _get_metainfo(self, index):
        question = dict()
        question['scene'] = gdef.translate_scene(self.scenes[index])

        question['image_index'] = index
        question['image_filename'] = gdef.get_image_filename(question['scene'])

        # program section
        question['program_raw'] = self.program
        question['program_seq'] = self.program
        question['program_tree'] = nsclseq_to_nscltree(question['program_seq'])
        question['program_qsseq'] = nsclseq_to_nsclqsseq(question['program_seq'])
        question['program_qstree'] = nscltree_to_nsclqstree(question['program_tree'])
        question['question_type'] = question['program_seq'][-1]['op']

        return question
Beispiel #4
0
    def _get_metainfo(self, index):
        question = dict()
        question["scene"] = gdef.translate_scene(self.scenes[index])

        question["image_index"] = index
        question["image_filename"] = gdef.get_image_filename(question["scene"])

        # program section
        question["program_raw"] = self.program
        question["program_seq"] = self.program
        question["program_tree"] = nsclseq_to_nscltree(question["program_seq"])
        question["program_qsseq"] = nsclseq_to_nsclqsseq(question["program_seq"])
        question["program_qstree"] = nscltree_to_nsclqstree(question["program_tree"])
        question["question_type"] = question["program_seq"][-1]["op"]

        return question
Beispiel #5
0
    def _get_metainfo(self, index):
        qid = index // len(VIEWS)
        view_id = index % len(VIEWS)
        question = gdef.translate_question(self.questions[qid])
        question = copydict(question)
        question["index"] = index
        scene = gdef.translate_scene(self.scenes[question["image_index"]])
        scene = copydict(scene)
        scene["objects_detection"] = scene["objects_detection"][VIEWS[view_id]]
        for obj in scene["objects"]:
            obj["mask"] = obj["mask"][VIEWS[view_id]]
        question["scene"] = scene
        # question["image_index"] = question["image_index"]
        question["view_id"] = view_id
        question["image_filename"] = osp.join(
            gdef.get_image_filename(scene), VIEWS[view_id] + ".png"
        )
        question["question_index"] = qid
        question["question_tokenized"] = nltk.word_tokenize(question["question"])
        # program section
        has_program = False
        if "program_nsclseq" in question:
            question["program_raw"] = question["program_nsclseq"]
            question["program_seq"] = question["program_nsclseq"]
            has_program = True
        elif "program" in question:
            question["program_raw"] = question["program"]
            question["program_seq"] = gdef.program_to_nsclseq(
                question["program"], question
            )
            has_program = True

        if has_program:
            question["program_tree"] = nsclseq_to_nscltree(question["program_seq"])
            question["program_qsseq"] = nsclseq_to_nsclqsseq(question["program_seq"])
            question["program_qstree"] = nscltree_to_nsclqstree(
                question["program_tree"]
            )
            question["question_type"] = question["program_seq"][-1]["op"]
        else:
            question["question_type"] = None
        return question