This paper firstly analyzes the Classification principle of SVM and indicates that SVM can not obtain favorable classification ability when the numbers of all classes of samples vary greatly. The algorithm of weighted SVM is put forward based on the analysis of the reason why the classification inclination comes into being, which can compensate the effect of the uneven class sizes and advance the classification accuracy of the smaller sample size. The experimental results of defect recognition in weld image show that this algorithm can improve the accuracy of small class effectively.