-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·84 lines (63 loc) · 2.77 KB
/
Copy pathrun.py
File metadata and controls
executable file
·84 lines (63 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
"""
Bio-Medical AI Competition - Evaluation Script
Simple evaluation script that supports metadata configuration
via command line arguments and configuration files.
Usage:
# Basic usage
python run.py # Run with defaults
# With metadata via config file
python run.py --config metadata_config.json
"""
import os
from eval_framework import CompetitionKit, load_and_merge_config, create_metadata_parser
def main():
# Create argument parser with metadata support
parser = create_metadata_parser()
args = parser.parse_args()
# Load configuration from config file if provided and merge with args
args = load_and_merge_config(args)
# Extract values dynamically with fallback defaults
output_file = getattr(args, 'output_file', "submission.csv")
dataset_name = getattr(args, 'dataset')
model_name = getattr(args, 'model_path', None) or getattr(args, 'model_name', None)
model_class = getattr(args, 'model_class', 'auto')
"""Run evaluation with metadata support"""
print("\n" + "="*60)
print("🏥 CURE-Bench Competition - Evaluation")
print("="*60)
# Initialize the competition kit
config_path = getattr(args, 'config', None)
# Use metadata_config.json as default if no config is specified
if not config_path:
default_config = "metadata_config.json"
if os.path.exists(default_config):
config_path = default_config
kit = CompetitionKit(config_path=config_path)
print(f"Loading model: {model_name}")
kit.load_model(model_name, model_class)
# Show available datasets
print("Available datasets:")
kit.list_datasets()
# Run evaluation (with optional subset_size)
subset_size = getattr(args, 'subset_size', None)
print(f"Running evaluation on dataset: {dataset_name} (subset-size={subset_size})")
results = kit.evaluate(dataset_name, subset_size=subset_size)
# Generate submission with metadata from config/args
print("Generating submission with metadata...")
submission_path = kit.save_submission_with_metadata(
results=[results],
filename=output_file,
config_path=getattr(args, 'config', None),
args=args
)
print(f"\n✅ Evaluation completed successfully!")
print(f"📊 Accuracy: {results.accuracy:.2%} ({results.correct_predictions}/{results.total_examples})")
print(f"📄 Submission saved to: {submission_path}")
# Show metadata summary if verbose
final_metadata = kit.get_metadata(getattr(args, 'config', None), args)
print("\n📋 Final metadata:")
for key, value in final_metadata.items():
print(f" {key}: {value}")
if __name__ == "__main__":
main()