grano1 commited on
Commit
547139e
Β·
verified Β·
1 Parent(s): 020f6ef

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -9
README.md CHANGED
@@ -14,26 +14,26 @@ tags:
14
  - geotechnics
15
  ---
16
 
17
- # Core Sample Main Fraction Classifier
18
 
19
  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 four class labels from cropped core sample images (300x300 pixels):
20
- - Clay (T)
21
- - Silt (U)
22
- - Sand (S)
23
- - Gravel (G)
24
 
25
- ## Metrics
26
 
27
  The following table summarizes selected metrics quantifying the model performance on the test set:
28
 
29
- | Metric | Value |
30
  |------------------------------------|--------|
31
  | Categorical Cross-Entropy Loss | 0.0998 |
32
  | Accuracy | 0.9606 |
33
  | F1-score (macro, aggregated) | 0.8195 |
34
  | F1-score (weighted, aggregated) | 0.9597 |
35
 
36
- ## Hyperparameters
37
 
38
  The following table summarizes selected hyperparameters used for training the model:
39
 
@@ -45,11 +45,53 @@ The following table summarizes selected hyperparameters used for training the mo
45
  | Metric for best model | Cat. CE |
46
  | Early stopping patience | 3 |
47
 
48
- ## Usage
49
 
50
  ```python
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  ```
52
 
 
 
53
 
54
  ## ✨ Citation
55
  If you use this model, please cite:
 
14
  - geotechnics
15
  ---
16
 
17
+ # πŸͺ¨ Core Sample Main Fraction Classifier
18
 
19
  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 four class labels from cropped core sample images (300x300 pixels):
20
+ - 🟀 Clay (T)
21
+ - 🀎 Silt (U)
22
+ - 🟑 Sand (S)
23
+ - βšͺ Gravel (G)
24
 
25
+ ## πŸ“Š Metrics
26
 
27
  The following table summarizes selected metrics quantifying the model performance on the test set:
28
 
29
+ | πŸ“ˆ Metric | Value |
30
  |------------------------------------|--------|
31
  | Categorical Cross-Entropy Loss | 0.0998 |
32
  | Accuracy | 0.9606 |
33
  | F1-score (macro, aggregated) | 0.8195 |
34
  | F1-score (weighted, aggregated) | 0.9597 |
35
 
36
+ ## βš™οΈ Hyperparameters
37
 
38
  The following table summarizes selected hyperparameters used for training the model:
39
 
 
45
  | Metric for best model | Cat. CE |
46
  | Early stopping patience | 3 |
47
 
48
+ ## πŸš€ Usage
49
 
50
  ```python
51
+ # Load the dataset
52
+ data_dataset = load_dataset("grano1/core_sample_image_data")
53
+
54
+ # Load image processor and model
55
+ processor = AutoImageProcessor.from_pretrained("grano1/core_sample_image_main_fraction_model")
56
+ model = AutoModelForImageClassification.from_pretrained("grano1/core_sample_image_main_fraction_model")
57
+ model.eval() # Set model to evaluation mode
58
+
59
+ # Show sample features
60
+ data_dataset["test"].features
61
+
62
+ # Select sample from test set
63
+ split = "test"
64
+ sample = data_dataset[split][2] # Pick one sample
65
+ image = sample["image"]
66
+ label = sample["HB"]
67
+
68
+ # Prepare input for model
69
+ inputs = processor(images=image, return_tensors="pt")
70
+
71
+ # Run inference
72
+ with torch.no_grad():
73
+ outputs = model(**inputs)
74
+ logits = outputs.logits
75
+ predicted_class = logits.argmax(dim=1).item()
76
+ print(sample)
77
+
78
+ # Get predicted and true label name
79
+ id2label = model.config.id2label
80
+ label2id = model.config.label2id
81
+ predicted_label_name = id2label[predicted_class]
82
+
83
+ # Show result
84
+ print(f"βœ… Predicted label: {predicted_label_name}")
85
+ print(f"🧾 True label: {sample['HB']}")
86
+
87
+ # Display image
88
+ plt.imshow(sample['image'])
89
+ plt.axis('off') # Hide axes
90
+ plt.show()
91
  ```
92
 
93
+ ## πŸ”’ Limitations
94
+ The `grano1/core_sample_image_data` dataset includes `HB` more labels than the four identified by the model. This may require binning procedures, e.g., fS => S. Details can be found in the citation documented below.
95
 
96
  ## ✨ Citation
97
  If you use this model, please cite: