Skip to content

Commit

Permalink
Refactor image-to-text evaluation tasks and update configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
pufanyi committed Dec 1, 2024
1 parent b89847a commit 5e23413
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
3 changes: 3 additions & 0 deletions lmms_eval/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ def _get_task_and_group(self, task_dir: str):
"yaml_path": yaml_path,
}
elif self._config_is_group(config):
if f.endswith("mix_evals_image2text.yaml"):
print(config)
# This is a group config
tasks_and_groups[config["group"]] = {
"type": "group",
Expand Down Expand Up @@ -477,6 +479,7 @@ def _get_task_and_group(self, task_dir: str):
else:
self.logger.debug(f"File {f} in {root} could not be loaded as a task or group")

print(tasks_and_groups["mix_evals_image2text"])
return tasks_and_groups


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dataset_path: MixEval/MixEval-X
dataset_kwargs:
video: true # a bit confusing, but this is because the official uses path to store image data, so we need to load it as a video dataset
cache_dir: mix_evals_image2text
lmms_eval_specific_kwargs:
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ group: mix_evals_image2text
task:
- mix_evals_image2text_mc
- mix_evals_image2text_freeform
# - mix_evals_video2text_openended

This file was deleted.

7 changes: 4 additions & 3 deletions lmms_eval/tasks/mix_evals/image2text/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def mix_evals_image2text_process_results_freeform(doc, result):

def mix_evals_image2text_aggregate_submissions(results, args, task):
now_date_time = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
submission_file_name = f"mix_evals_video2text_{task}-{now_date_time}.json"
submission_file_name = f"mix_evals_image2text_{task}-{now_date_time}.json"
path = file_utils.generate_submission_file(submission_file_name, args)
with open(path, "w") as f:
json.dump(results, f)
Expand Down Expand Up @@ -365,8 +365,9 @@ def apply(self, resps, docs):
# response.raise_for_status()

# content =["choices"][0]["message"]["content"].strip()
content = response.choices[0].message.content.strip()
if content != "":
content = response.choices[0].message.content
if content:
content = content.strip()
match = re.search(r"r'\b([A-Z])\.?\b'", content)
if match:
result = ord(match.group(1)) - ord("A")
Expand Down

0 comments on commit 5e23413

Please sign in to comment.