mirror of
https://github.com/VikParuchuri/surya.git
synced 2026-06-04 21:03:53 +08:00
52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
import json
|
|
import argparse
|
|
|
|
|
|
def verify_layout(data):
|
|
scores = data["metrics"]
|
|
for layout_type, metrics in scores.items():
|
|
if metrics["precision"] <= 0.6 or metrics["recall"] <= 0.6:
|
|
raise ValueError("Scores do not meet the required threshold")
|
|
|
|
|
|
def verify_det(data):
|
|
scores = data["metrics"]["surya"]
|
|
if scores["precision"] <= 0.9 or scores["recall"] <= 0.9:
|
|
raise ValueError("Scores do not meet the required threshold")
|
|
|
|
|
|
def verify_rec(data):
|
|
scores = data["surya"]
|
|
if scores["avg_score"] <= 0.9:
|
|
raise ValueError("Scores do not meet the required threshold")
|
|
|
|
|
|
def verify_order(data):
|
|
score = data["mean_accuracy"]
|
|
if score < 0.75:
|
|
raise ValueError("Scores do not meet the required threshold")
|
|
|
|
|
|
def verify_scores(file_path, bench_type):
|
|
with open(file_path, 'r') as file:
|
|
data = json.load(file)
|
|
|
|
if bench_type == "detection":
|
|
verify_det(data)
|
|
elif bench_type == "recognition":
|
|
verify_rec(data)
|
|
elif bench_type == "layout":
|
|
verify_layout(data)
|
|
elif bench_type == "ordering":
|
|
verify_order(data)
|
|
else:
|
|
raise ValueError("Invalid benchmark type")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Verify benchmark scores")
|
|
parser.add_argument("file_path", type=str, help="Path to the json file")
|
|
parser.add_argument("--bench_type", type=str, help="Type of benchmark to verify", default="detection")
|
|
args = parser.parse_args()
|
|
verify_scores(args.file_path, args.bench_type)
|