[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2026-01-12 23:29:15 +00:00
parent 22884d2bf7
commit d84e3c70b7
16 changed files with 270 additions and 143 deletions

View file

@ -31,7 +31,12 @@ class BLINK(EvalBase):
except Exception as e:
print(f"Warning: Could not load BLINK: {e}")
try:
tasks = ["Counting", "Spatial_Relation", "Object_Localization", "Visual_Similarity"]
tasks = [
"Counting",
"Spatial_Relation",
"Object_Localization",
"Visual_Similarity",
]
all_data = []
for t in tasks:
try:
@ -88,15 +93,19 @@ class BLINK(EvalBase):
content = []
for img_b64 in images:
content.append({
"type": "image_url",
"image_url": {"url": f"data:image/png;base64,{img_b64}"},
})
content.append(
{
"type": "image_url",
"image_url": {"url": f"data:image/png;base64,{img_b64}"},
}
)
content.append({"type": "text", "text": prompt})
return [{"role": "user", "content": content}]
def extract_answer(self, response: str, num_choices: int) -> Tuple[Optional[str], str]:
def extract_answer(
self, response: str, num_choices: int
) -> Tuple[Optional[str], str]:
valid_letters = set(ascii_uppercase[:num_choices])
letter, method = extract_letter_from_answer_tag(response, valid_letters)
@ -130,9 +139,12 @@ class BLINK(EvalBase):
answer = data_item.get("answer", "")
num_choices = sum(
1 for letter in ascii_uppercase[:6]
if letter in data_item and data_item[letter] is not None
and isinstance(data_item[letter], str) and data_item[letter].strip()
1
for letter in ascii_uppercase[:6]
if letter in data_item
and data_item[letter] is not None
and isinstance(data_item[letter], str)
and data_item[letter].strip()
)
num_choices = max(num_choices, 4)