-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschemas.py
64 lines (49 loc) · 1.59 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from pydantic import BaseModel
from typing import Optional, List, Dict, Union, NewType
SemArtImageName = NewType("SemArtImageName", str)
class TrainingRecord(BaseModel):
dataset: str
image: str
question: str
question_id: int
answer: Optional[List[str]] = None
rationales: Optional[List[str]] = None
class TestingRecord(BaseModel):
question_id: int
question: str
image: str
dataset: Optional[str]
original_question_id: Optional[Union[int, str]]
# AOKVQA has string type question ids.
class AnswerRecord(BaseModel):
question_id: Union[int, str]
answer: str
score: float
class QuestionRecord(BaseModel):
# For datasets which use COCO images, the image_id is the COCO image id.
# SemArt doesn't have image ids but names, so we use the names.
image_id: Union[int, SemArtImageName]
question: str
question_id: int
class VQAAnnotationSubRecord(BaseModel):
answer: str
answer_confidence: str
answer_id: int
class VQAAnnotationRecord(BaseModel):
question_type: str
answers: List[VQAAnnotationSubRecord]
image_id: Union[int, SemArtImageName]
answer_type: str
question_id: int
multiple_choice_answer: Optional[str] = None
# This can be used for VQA datasets that only have
# one ground truth answer per question, and so can't
# be used easily with the VQAv2 evaluation code.
class MinimalEvaluationRecord(BaseModel):
question_id: int
answer: str
question: str
image: Union[str, int]
question_type: Optional[str] = None
answer_type: Optional[str] = None
dataset: Optional[str] = None