Spaces:
Sleeping
Sleeping
Download challenges/object_localization/validate.py from VizWiz-Challenges/evaluationServer: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/VizWiz-Challenges/evaluationServer/resolve/main/challenges/object_localization/validate.py
- Command line
-
hf download hf://spaces/VizWiz-Challenges/evaluationServer/challenges/object_localization/validate.py
-
curl -L -o validate.py https://huggingface.co/spaces/VizWiz-Challenges/evaluationServer/resolve/main/challenges/object_localization/validate.py
1.45 kB
| from typing import Any, Tuple | |
| def validate_submission(obj: Any) -> Tuple[bool, str]: | |
| if not isinstance(obj, list): | |
| return False, "Submission must be a JSON list of annotations." | |
| required_keys = {"image_id", "score", "category_id", "area", "bbox", "segmentation"} | |
| for i, ann in enumerate(obj): | |
| if not isinstance(ann, dict): | |
| return False, f"Annotation at index {i} must be an object/dict." | |
| missing = required_keys - set(ann.keys()) | |
| if missing: | |
| return False, f"Annotation at index {i} missing keys: {sorted(list(missing))}" | |
| if not isinstance(ann["image_id"], int): | |
| return False, f"image_id at index {i} must be an integer." | |
| if not isinstance(ann["category_id"], int): | |
| return False, f"category_id at index {i} must be an integer." | |
| if not isinstance(ann["score"], (int, float)): | |
| return False, f"score at index {i} must be a number." | |
| if not isinstance(ann["area"], (int, float)): | |
| return False, f"area at index {i} must be a number." | |
| bbox = ann["bbox"] | |
| if not (isinstance(bbox, list) and len(bbox) == 4 | |
| and all(isinstance(x, (int, float)) for x in bbox)): | |
| return False, f"bbox at index {i} must be a list of 4 numbers." | |
| if not isinstance(ann["segmentation"], list): | |
| return False, f"segmentation at index {i} must be a list." | |
| return True, "OK" | |