Downloads · 30 days
26
27% of all-time downloads
vivekkopthsd/steel-defect-resnet18
steel-defect-resnet18 is a image classification model from vivekkopthsd. Use it when you need a label for an image. It is set up for pytorch. The card lists the license as mit.
Classifies hot-rolled steel surface defects into 6 classes (rolled-in scale, patches, crazing, pitted surface, inclusion, scratches) with a ResNet18 fine-tuned on the real NEU-DET database. Grad-CAM heatmaps included…
Downloads · 30 days
26
27% of all-time downloads
All-time downloads
97
Public
Parameters
11.2M
46.9 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors44.8 MB · 95%
From the Hugging Face model README
Classifies hot-rolled steel surface defects into 6 classes (rolled-in scale, patches, crazing, pitted surface, inclusion, scratches) with a ResNet18 fine-tuned on the real NEU-DET database. Grad-CAM heatmaps included for explainability.
| Metric | Value |
|---|---|
| Test accuracy | 0.985 |
| Test ROC-AUC (one-vs-rest) | 0.9999 |
| Macro F1 | 0.985 |
| Class | Precision | Recall | F1 |
|---|---|---|---|
| Rolled-in Scale | 1.000 | 1.000 | 1.000 |
| Patches | 1.000 | 0.977 | 0.989 |
| Crazing | 0.957 | 1.000 | 0.978 |
| Pitted Surface | 1.000 | 0.955 | 0.977 |
| Inclusion | 0.977 | 0.977 | 0.977 |
| Scratches | 0.978 | 1.000 | 0.989 |
import json
import torch
from safetensors.torch import load_file
from torchvision import models
from torchvision.transforms import Compose, Resize, ToTensor, Normalize
cfg = json.load(open("config.json"))
model = models.resnet18(weights=None)
model.fc = torch.nn.Linear(model.fc.in_features, len(cfg["class_names"]))
model.load_state_dict(load_file("model.safetensors"))
model.eval()
tf = Compose([Resize((cfg["img_size"], cfg["img_size"])), ToTensor(),
Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])
img = tf(Image.open("patch.jpg").convert("RGB")).unsqueeze(0)
prob = torch.softmax(model(img), 1)[0]
label = cfg["class_names"][prob.argmax().item()]
print(f"{label}: {prob.max().item():.3f}")
Grad-CAM overlays for each class and misclassified samples:
figures/gradcam_all_classes.png, figures/gradcam_misclassified.png.