File size: 1,742 Bytes
b974978 080565f b974978 f3b2c98 080565f b974978 080565f b974978 | 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 | ---
library_name: pytorch
pipeline_tag: image-segmentation
tags:
- image-segmentation
- segmentation-models-pytorch
- defect-detection
---
# Industrial surface defect segmentation
Pixel level segmentation of four surface defect classes on 128 x 800 grayscale inspection images.
Exported from run `run_fold0_v16_5h`: variant `blend_mean`, validation score 0.7927
(0.7 x dice on defect pairs + 0.3 x empty accuracy), dice on defects 0.7245, empty accuracy 0.9518.
On the earlier runs the public leaderboard score was about 0.045 below this validation score.
## Models
| name | decoder | encoder | blend weight | validation score |
|---|---|---|---|---|
| fpn_convnext_small | FPN | tu-convnext_small.in12k_ft_in1k | 1.000 | 0.7813 |
| fpn_convnext_small_hr | FPN | tu-convnext_small.in12k_ft_in1k | 1.000 | 0.7876 |
| fpn_convnext_small_seed2 | FPN | tu-convnext_small.in12k_ft_in1k | 1.000 | 0.7856 |
| unet_mambaout_tiny | Unet | tu-mambaout_tiny.in1k | 1.000 | 0.767 |
## Per class decision rule
A class is predicted when the averaged classifier output is at least `cls_thr` and at least `area` pixels have
probability above `det_thr`; the mask is then every pixel above `thr`.
| class | thr | det_thr | area | cls_thr | validation dice |
|---|---|---|---|---|---|
| defect_a | 0.35 | 0.45 | 100 | 0.2 | 0.5435 |
| defect_b | 0.6 | 0.6 | 400 | 0.0 | 0.5283 |
| defect_c | 0.45 | 0.65 | 150 | 0.0 | 0.7524 |
| defect_d | 0.4 | 0.5 | 200 | 0.0 | 0.8074 |
## Usage
```python
from inference import DefectSegmenter, read_gray, mask_to_rle
model = DefectSegmenter(".")
masks = model.predict(read_gray("image.jpg"))
print({k: mask_to_rle(v) for k, v in masks.items()})
```
`python app.py` starts a Gradio demo. Test time flips: h, v, hv.
|