mirror of
https://github.com/NousResearch/atropos.git
synced 2026-04-23 16:54:56 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
22884d2bf7
commit
d84e3c70b7
16 changed files with 270 additions and 143 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue