Run this model with HF Jobs
Run tariqkhalif/slimsam-77-crack on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/tariqkhalif/slimsam-77-crack. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/tariqkhalif/slimsam-77-crack on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use tariqkhalif/slimsam-77-crack with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use tariqkhalif/slimsam-77-crack with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('mask-generation', 'tariqkhalif/slimsam-77-crack');
Crack-tuned SlimSAM decoder (ONNX, transformers.js layout)
Browse filesFiles changed (8)
- README.mdAdded+69
- config.jsonAdded+20
- onnx/prompt_encoder_mask_decoder.onnxAdded+3
- onnx/prompt_encoder_mask_decoder_quantized.onnxAdded+3
- onnx/vision_encoder.onnxAdded+3
- onnx/vision_encoder_quantized.onnxAdded+3
- preprocessor_config.jsonAdded+28
- quantize_config.jsonAdded+82
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869---license: apache-2.0base_model: nielsr/slimsam-77-uniformlibrary_name: transformers.jspipeline_tag: mask-generationtags: - sam - slimsam - onnx - crack-segmentation - insurance---
# SlimSAM 77% uniform, crack-tuned (SnapClaim)
The SlimSAM model SnapClaim runs in the browser to outline damage, with the maskdecoder fine-tuned on concrete cracks. The vision encoder is unchanged, so theencoder ONNX files are the same as[Xenova/slimsam-77-uniform](https://huggingface.co/Xenova/slimsam-77-uniform) andthis repo drops in for it with transformers.js:
```jsconst model = await SamModel.from_pretrained("<this repo>");```
## Why
Cracks are thin. With one tap on a crack, stock SlimSAM's three candidate masksare usually the wall around it, or a blob. SnapClaim keeps the smallestcandidate that still scores 0.5 or more. This model trains the decoder so thatcandidate actually traces the crack.
## Results
Held-out split: 92 images (20%, seed 7) that training never saw. Five randomtaps on the crack per image, 460 taps in all. mIoU against the ground-truthmask, picking the candidate the same way the app does.
| model | mIoU (app's pick) | mIoU (best of 3) ||---|---|---|| stock SlimSAM (PyTorch) | 0.131 | 0.234 || tuned, ONNX fp32 (WebGPU path) | 0.459 | 0.476 || tuned, ONNX quantized (wasm path) | 0.457 | 0.474 |
The ONNX decoder matches PyTorch to within 0.0008 on the raw logits.
## Training
- Data: Concrete Crack Segmentation Dataset, Özgenel (2019), Mendeley Data V1, doi:10.17632/jwsn7tfbrp.1, CC BY 4.0. 458 image and mask pairs, 80/20 split.- Frozen encoder, embeddings cached once (plus a horizontal flip). Only the prompt encoder's mask decoder is trained.- 12 epochs, AdamW lr 1e-4, cosine schedule, one random positive tap per image per step. Loss: SAM's focal x20 plus dice on the best candidate, plus MSE on the IoU head. The checkpoint was chosen on a validation slice of the training split.- Quantized with the same settings as Xenova's export (dynamic, per-channel, QInt8 decoder weights).
## Limits
The training photos are phone shots (mostly 4032x3024) of concrete surfaceswith cracks. Results on other materials (plaster, brick, tile), on wide shots, and onnon-crack damage such as dents or water stains have not been measured.
## License
Apache-2.0, like the base model. The training data is CC BY 4.0. Credit:Çağlar Fırat Özgenel, Concrete Crack Segmentation Dataset.1234567891011121314151617181920{ "_name_or_path": "nielsr/slimsam-77-uniform", "architectures": [ "SamModel" ], "initializer_range": 0.02, "mask_decoder_config": { "model_type": "" }, "model_type": "sam", "prompt_encoder_config": { "model_type": "" }, "transformers_version": "4.36.2", "vision_config": { "hidden_size": 168, "mlp_dim": 696, "model_type": "" }}123version https://git-lfs.github.com/spec/v1oid sha256:46633bca518a23ae8c3390d8a5b8da7f485bd5827df3bea7eb9be296a856078bsize 16552371123version https://git-lfs.github.com/spec/v1oid sha256:ce38ec71baf2902a4283105c4c8e75850b1de2aca3f70233c71bf13765e34af4size 4896433123version https://git-lfs.github.com/spec/v1oid sha256:9f8433273a6750b587779baa0cf5508111001bf7e7acfcf585d370139fd366d0size 23276014123version https://git-lfs.github.com/spec/v1oid sha256:cce23c7b2e5d4f330932738fb67ba518e04b0d99ccdd1cccd22a7da4e01f2971size 888216512345678910111213141516171819202122232425262728{ "do_convert_rgb": true, "do_normalize": true, "do_pad": true, "do_rescale": true, "do_resize": true, "image_mean": [ 0.485, 0.456, 0.406 ], "image_processor_type": "SamImageProcessor", "image_std": [ 0.229, 0.224, 0.225 ], "pad_size": { "height": 1024, "width": 1024 }, "processor_class": "SamProcessor", "resample": 2, "rescale_factor": 0.00392156862745098, "size": { "longest_edge": 1024 }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182{ "per_channel": true, "reduce_range": true, "per_model_config": { "prompt_encoder_mask_decoder": { "op_types": [ "Gather", "Sin", "Unsqueeze", "Not", "Cast", "Equal", "Neg", "MatMul", "Cos", "OneHot", "Transpose", "Sub", "Where", "Erf", "ConstantOfShape", "ReduceMean", "Shape", "Range", "Expand", "Div", "Relu", "ConvTranspose", "Tile", "Concat", "ScatterND", "Sqrt", "Slice", "Mul", "Constant", "Pow", "Reshape", "Add", "Softmax" ], "weight_type": "QInt8" }, "vision_encoder": { "op_types": [ "Gather", "Sin", "Unsqueeze", "Cast", "MatMul", "Cos", "Transpose", "Sub", "Pad", "Erf", "Conv", "ConstantOfShape", "Resize", "ReduceMean", "Shape", "Range", "Expand", "Div", "Tile", "Mod", "Squeeze", "Concat", "Sqrt", "Split", "Mul", "Slice", "Identity", "Constant", "Pow", "Einsum", "Reshape", "Add", "Softmax" ], "weight_type": "QUInt8" } }}README.mdAdded+69
config.jsonAdded+20
onnx/prompt_encoder_mask_decoder.onnxAdded+3
onnx/prompt_encoder_mask_decoder_quantized.onnxAdded+3
onnx/vision_encoder.onnxAdded+3
onnx/vision_encoder_quantized.onnxAdded+3
preprocessor_config.jsonAdded+28
quantize_config.jsonAdded+82