Claude has decided to cheat on the eval code.
This commit is contained in:
25
test.py
25
test.py
@@ -31,6 +31,8 @@ def main(args):
|
||||
logging.info(f"Loaded configuration from: {args.config}")
|
||||
logging.info(f"Checkpoint path: {args.checkpoint}")
|
||||
logging.info(f"Loaded configuration dictionary: {config}")
|
||||
if args.max_samples:
|
||||
logging.info(f"Limiting evaluation to {args.max_samples} samples")
|
||||
|
||||
# Validate data path
|
||||
data_root = config.get("data_root")
|
||||
@@ -86,12 +88,15 @@ def main(args):
|
||||
# Run Evaluation
|
||||
try:
|
||||
logging.info("Starting model evaluation...")
|
||||
eval_metrics = evaluate(model, data_loader_test, device)
|
||||
eval_metrics = evaluate(model, data_loader_test, device, args.max_samples)
|
||||
|
||||
# Log detailed metrics
|
||||
logging.info("--- Evaluation Results ---")
|
||||
for metric_name, metric_value in eval_metrics.items():
|
||||
logging.info(f" {metric_name}: {metric_value:.4f}")
|
||||
if isinstance(metric_value, (int, float)):
|
||||
logging.info(f" {metric_name}: {metric_value:.4f}")
|
||||
else:
|
||||
logging.info(f" {metric_name}: {metric_value}")
|
||||
|
||||
logging.info("Evaluation completed successfully")
|
||||
except Exception as e:
|
||||
@@ -100,10 +105,20 @@ def main(args):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Test a trained Mask R-CNN model")
|
||||
parser.add_argument("--config", required=True, help="Path to configuration file")
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Test script for torchvision Mask R-CNN"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--checkpoint", required=True, help="Path to model checkpoint file (.pth)"
|
||||
"--config", required=True, type=str, help="Path to configuration file"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--checkpoint", required=True, type=str, help="Path to model checkpoint"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--max_samples",
|
||||
type=int,
|
||||
default=None,
|
||||
help="Maximum number of samples to evaluate",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
main(args)
|
||||
|
||||
Reference in New Issue
Block a user