HFswapnil's picture
Update challenges/vqa/validate.py
8842e13 verified
Raw
History Blame Contribute Delete
1.14 kB
from typing import Any, Tuple
def validate_submission(obj: Any) -> Tuple[bool, str]:
"""Validate VQA Answer Therapy submission format."""
if not isinstance(obj, list):
return False, "Submission must be a JSON list of result objects."
if len(obj) == 0:
return False, "Submission list is empty."
for i, item in enumerate(obj):
if not isinstance(item, dict):
return False, f"Entry at index {i} must be a JSON object."
if "image" not in item:
return False, f"Entry at index {i} missing 'image'."
if "answer" not in item:
return False, f"Entry at index {i} missing 'answer'."
# if not isinstance(item["question_id"], str):
# return False, f"'question_id' at index {i} must be a string."
# sg = item["single_grounding"]
# if not isinstance(sg, (int, float)):
# return False, f"'single_grounding' at index {i} must be a float (0=multiple, 1=single)."
# if not (0.0 <= float(sg) <= 1.0):
# return False, f"'single_grounding' at index {i} must be between 0.0 and 1.0."
return True, "OK"