Automatisk skadedetektering av pennor med maskininlärning
2026 (Swedish)Independent thesis Basic level (university diploma), 10 credits / 15 HE credits
Student thesisAlternative title
Automatic Damage Detection of Pencils Using Machine Learning (English)
Abstract [sv]
Automatiserad bildklassificering kan användas som stöd inom kvalitetskontroll för att identifiera defekta produkter och analysera olika typer av avvikelser. Syftet med detta arbete var att jämföra prestandan hos DT, SVM och CNN vid binär bildklassificering av pennor samt undersöka hur modellernas prestanda förändrades när klassificeringen utökades till multiklassklassificering. Klassificeringen genomfördes först som en binär uppgift, där pennorna delades in i klasserna hel och bruten. Därefter utökades uppgiften till multiklassklassificering, där den brutna klassen delades upp i bruten typ 1 och bruten typ 2. För SVM och DT användes HOG för att extrahera bildegenskaper, medan CNN tränades direkt på bilddata. Modellerna utvärderades genom flera körningar med hjälp av noggrannhet, precision, recall, F1-värde och confusion matrices.Resultaten visade att CNN presterade bäst i genomsnitt vid den binära klassificeringen och hade högst recall för den brutna klassen. Detta innebär att CNN hade bäst förmåga att identifiera brutna pennor i den binära delen av studien. DT och SVM låg något lägre i flera mått, men DT visade mer stabila resultat mellan körningarna. Vid multiklassklassificering gav den mer detaljerade klassindelningen en tydligare bild av hur modellerna hanterade olika defekttyper. Bruten typ 2 identifierades med hög recall av samtliga modeller när den fick en egen klass. Samtidigt visade resultaten att CNN hade större variation mellan körningarna. Även om CNN hade högst genomsnittlig noggrannhet i multiklassdelen var skillnaden mot DT liten, samtidigt som DT visade betydligt stabilare resultat. DT framstod därför som det mest balanserade alternativet i multiklassdelen av studien, eftersom modellen nådde nära samma resultat som CNN men med enklare uppbyggnad, högre tolkningsbarhet och lägre variation. Arbetet visar därmed att bildbaserad maskininlärning kan användas för klassificering av pennor på det aktuella datasetet, men att resultatet påverkas av modellval, klassindelning, datamängd och förbehandling. Slutsatserna bör därför tolkas utifrån studiens förutsättningar och inte som ett generellt svar på vilken modell som är bäst för all bildbaserad defektklassificering.
Abstract [en]
Automated image classification can be used as a support tool in quality control to identify defective products and analyze different types of deviations. The purpose of this thesis was to compare the performance of DT, SVM and CNN in binary image classification of pencils, and to examine how the models’ performance changed when the classification task was extended to multiclass classification. The classification was first performed as a binary task, where the pencils were divided into the classes whole and broken. The task was then extended to multiclass classification, where the broken class was divided into broken type 1 and broken type 2. For SVM and DT, HOG was used to extract image features, while the CNN model was trained directly on image data. The models were evaluated through several runs using accuracy, precision, recall, F1-score and confusion matrices. The results showed that CNN achieved the highest average performance in the binary classification and had the highest recall for the broken class. This means that CNN had the strongest ability to identify broken pencils in the binary part of the study. DT and SVM achieved slightly lower results in several metrics, but DT showed more stable performance between runs. In the multiclass classification, the more detailed class division provided a clearer view of how the models handled different defect types. Broken type 2 was identified with high recall by all models when it was treated as a separate class. At the same time, CNN showed greater variation between runs. Although CNN achieved the highest average accuracy in the multiclass task, the difference compared with DT was small, while DT showed considerably more stable results. Therefore, DT appeared to be the most balanced alternative in the multiclass part of the study, as it achieved results close to CNN while having a simpler structure, higher interpretability and lower variation. This thesis shows that image-based machine learning can be used for pencil classification on the current dataset, but that the results are affected by model choice, class division, data size and preprocessing. The conclusions should therefore be interpreted within the conditions of this study, rather than as a general answer to which model is best for all image-based defect classification tasks.
Place, publisher, year, edition, pages
2026.
Keywords [sv]
Maskininlärning, Bildklassificering, Convolutional Neural Network, Support Vector Machine, Decision Tree
National Category
Engineering and Technology
Identifiers
URN: urn:nbn:se:hb:diva-35814OAI: oai:DiVA.org:hb-35814DiVA, id: diva2:2082930
Subject / course
Maskinteknik - Högskoleingenjör
Supervisors
Examiners
2026-07-012026-07-012026-07-01Bibliographically approved