Intelligent system for defect detection