File size: 2,345 Bytes
f88a971
 
33401aa
f88a971
33401aa
 
 
 
 
 
f88a971
 
33401aa
f88a971
 
33401aa
 
 
 
 
 
 
 
 
 
 
 
 
f88a971
 
80e61f2
f88a971
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
language:
- en
tags:
- defect-detection
- image-classification
- machine-learning
- quality-control
- ensemble-learning
- neural-networks
license: apache-2.0
datasets:
- custom_paper_surface_defect
pipeline_tag: image-classification
model-index:
- name: Paper Defect Detection
  results:
  - task:
      type: image-classification
      name: Surface Defect Detection
    metrics:
    - type: accuracy
      value: 0.81
      name: Ensemble Test Accuracy
    - type: f1
      value: 0.8
      name: F1 Score
library_name: sklearn
---

# Paper Defect Detection

## Model Description

This model is designed for automated surface defect detection in manufacturing using a hybrid approach that combines classical machine learning and deep learning techniques.

### Model Architecture

The model uses a hybrid architecture combining:
- Logistic Regression
- SVM
- Naive Bayes
- CNN
- Ensemble Voting Classifier

### Feature Extraction Methods
- Histogram of Oriented Gradients (HOG)
- Gabor Filters
- Canny Edge Detection
- Wavelet Transforms

## Performance

| Model               | Train Accuracy | Test Accuracy |
|--------------------|----------------|---------------|
| Logistic Regression| 0.99          | 0.79         |
| SVM                | 0.86          | 0.80         |
| Ensemble Model     | 0.90          | 0.81         |

## Limitations

- Performance may degrade for defect types not represented in the training data
- Variations in lighting or textures can affect classification accuracy
- This was a university project with room for improvement

## Usage

```python
from transformers import AutoModelForImageClassification, AutoFeatureExtractor
import torch
from PIL import Image
from torchvision import transforms

model_name = "your-username/surface-defect-detection"
model = AutoModelForImageClassification.from_pretrained(model_name)
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)

# Preprocess the input image
transform = transforms.Compose([
    transforms.Resize((128, 128)),
    transforms.ToTensor()
])

image = Image.open("path/to/sample-image.jpg")
inputs = feature_extractor(images=image, return_tensors="pt")

# Perform inference
with torch.no_grad():
    outputs = model(**inputs)
    predicted_class = outputs.logits.argmax(-1).item()

print(f"Predicted Defect Class: {predicted_class}")
```