File size: 3,667 Bytes
b4a8cf0 5111542 efe8504 8fed09b |
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
---
license: mit
datasets:
- grano1/core_sample_image_data
language:
- en
metrics:
- accuracy
- f1
base_model:
- microsoft/swinv2-tiny-patch4-window16-256
pipeline_tag: image-classification
tags:
- geotechnics
---
# ๐ชจ Core Sample Secondary Fraction Classifier
This multi-label classification model was fine-tuned for automated visual analysis of soil core samples, and trained / validated / tested on the `grano1/core_sample_image_data` dataset available via the HuggingFace eco-system. The model aims to predict one of the following nine class labels - termed in accordance with DIN 4023 - from cropped core sample images (300x300 pixels):
- very gravelly | gravelly (g* | g)
- very sandy | sandy (s* | s)
- very silty | silty (u* | u)
- very clayey | clayey (t* | t)
- stony (x)
## ๐ Metrics
The following table summarizes selected metrics quantifying the model performance on the test set:
| ๐ Metric | Value |
|------------------------------------|--------|
| Binary Cross-Entropy Loss | 0.1146 |
| Subset Accuracy | 0.7606 |
| F1-score (macro, aggregated) | 0.7734 |
| F1-score (weighted, aggregated) | 0.8124 |
| Hamming Loss | 0.0363 |
## โ๏ธ Hyperparameters
The following table summarizes selected hyperparameters used for training the model:
| Metric | Value |
|---------------------------|----------|
| Batch size | 16 |
| Optimizer | AdamW |
| Warm-up ratio | 0.1 |
| Metric for best model | Bin. CE |
| Early stopping patience | 3 |
| Threshold | 0.3 |
## ๐ Usage
```python
# Load the dataset
data_dataset = load_dataset("grano1/core_sample_image_data")
# Load image processor and model
processor = AutoImageProcessor.from_pretrained("grano1/core_sample_image_secondary_fraction_model")
model = AutoModelForImageClassification.from_pretrained("grano1/core_sample_image_secondary_fraction_model")
model.eval() # Set model to evaluation mode
# Show sample features
data_dataset["test"].features
# Select sample from test set
split = "test"
sample = data_dataset[split][5] # Pick one sample
image = sample["image"]
# Prepare input for model
inputs = processor(images=image, return_tensors="pt")
# Run inference
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
predicted_class = logits.argmax(dim=1).item()
print(sample)
# Get predicted and true label name
id2label = model.config.id2label
label2id = model.config.label2id
predicted_label_name = id2label[predicted_class]
# Show result
print(f"โ
Predicted label: {predicted_label_name}")
print(f"๐งพ True label: {sample['NB']}")
# Display image
plt.imshow(sample['image'])
plt.axis('off') # Hide axes
plt.show()
```
## ๐ Limitations
The `grano1/core_sample_image_data` dataset includes more `NB` labels than the nine identified by this model. This may require data cleansing procedures, e.g., s' (slightly sandy) label has been removed. Instructions can be found in the citation documented below.
## โจ Citation
If you use this model, please cite:
```bibtex
@inproceedings{Granitzer.2025,
author = {Granitzer, Andreas-Nizar and Beck, Johannes and Leo, Johannes and Tschuchnigg, Franz},
title = {Explainable Insight into the Vision-Based Classification of Soil Core Samples from Close-Range Images},
pages = {228--233},
editor = {Uzielli, Marco and Phoon, Kok-Kwang},
booktitle = {Proceedings of the 3rd Workshop on the Future of Machine Learning in Geotechnics (3FOMLIG)},
year = {2025},
address = {Florence, Italy}
} |