Hyperparameter tuning for defect detection