Update README.md
Browse files
README.md
CHANGED
@@ -5,31 +5,32 @@ tags: []
|
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
-
|
9 |
-
|
10 |
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
### Model Description
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
- **Developed by:** [More Information Needed]
|
21 |
- **Funded by [optional]:** [More Information Needed]
|
22 |
- **Shared by [optional]:** [More Information Needed]
|
23 |
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model
|
27 |
|
28 |
### Model Sources [optional]
|
29 |
|
30 |
<!-- Provide the basic links for the model. -->
|
31 |
|
32 |
-
- **Repository:** [
|
33 |
- **Paper [optional]:** [More Information Needed]
|
34 |
- **Demo [optional]:** [More Information Needed]
|
35 |
|
@@ -69,9 +70,31 @@ Users (both direct and downstream) should be made aware of the risks, biases and
|
|
69 |
|
70 |
## How to Get Started with the Model
|
71 |
|
72 |
-
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
## Training Details
|
77 |
|
|
|
5 |
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
+
SegFormer model with a MiT-b2 backbone fine-tuned on Coralscapes at resolution 1024x1024, as introduced in ...
|
|
|
9 |
|
10 |
|
11 |
## Model Details
|
12 |
|
13 |
### Model Description
|
14 |
|
15 |
+
Training is conducted following \cite{xie2021segformer}, using a batch size of 8 for 265 epochs,
|
16 |
+
using the AdamW optimizer with an initial learning rate of 6e-5 (multiplied by 10 when using LoRA),
|
17 |
+
weight decay of 1e-2 and polynomial learning rate scheduler with a power of 1.
|
18 |
+
During training, images are randomly scaled within a range of 1 and 2, flipped horizontally with a 0.5 probability and randomly cropped to 1024×1024 pixels.
|
19 |
+
Input images are normalized using the ImageNet mean and standard deviation. For evaluation, a non-overlapping sliding window strategy is employed,
|
20 |
+
using a window size of 1024x1024 and a stride of 1024.
|
21 |
|
22 |
- **Developed by:** [More Information Needed]
|
23 |
- **Funded by [optional]:** [More Information Needed]
|
24 |
- **Shared by [optional]:** [More Information Needed]
|
25 |
- **Model type:** [More Information Needed]
|
|
|
26 |
- **License:** [More Information Needed]
|
27 |
+
- **Finetuned from model:** [SegFormer (b2-sized) encoder pre-trained-only (`nvidia/mit-b2`)](https://huggingface.co/nvidia/mit-b2)
|
28 |
|
29 |
### Model Sources [optional]
|
30 |
|
31 |
<!-- Provide the basic links for the model. -->
|
32 |
|
33 |
+
- **Repository:** [coralscapesScripts](https://github.com/ViktorDomazetoski/coralscapesScripts/)
|
34 |
- **Paper [optional]:** [More Information Needed]
|
35 |
- **Demo [optional]:** [More Information Needed]
|
36 |
|
|
|
70 |
|
71 |
## How to Get Started with the Model
|
72 |
|
73 |
+
Here is how to use this model to segment an image of the Coralscapes dataset
|
74 |
|
75 |
+
```python
|
76 |
+
from transformers import SegformerImageProcessor, SegformerForSemanticSegmentation
|
77 |
+
from PIL import Image
|
78 |
+
from datasets import load_dataset
|
79 |
+
import numpy as np
|
80 |
+
|
81 |
+
# Load an image from the coralscapes dataset or load your own image
|
82 |
+
dataset = load_dataset("EPFL-ECEO/coralscapes")
|
83 |
+
image = dataset["test"][42]["image"]
|
84 |
+
label = dataset["test"][42]["label"]
|
85 |
+
|
86 |
+
id2label = {"0": "unlabeled", "1": "seagrass", "2": "trash", "3": "other coral dead", "4": "other coral bleached", "5": "sand", "6": "other coral alive", "7": "human", "8": "transect tools", "9": "fish", "10": "algae covered substrate", "11": "other animal", "12": "unknown hard substrate", "13": "background", "14": "dark", "15": "transect line", "16": "massive/meandering bleached", "17": "massive/meandering alive", "18": "rubble", "19": "branching bleached", "20": "branching dead", "21": "millepora", "22": "branching alive", "23": "massive/meandering dead", "24": "clam", "25": "acropora alive", "26": "sea cucumber", "27": "turbinaria", "28": "table acropora alive", "29": "sponge", "30": "anemone", "31": "pocillopora alive", "32": "table acropora dead", "33": "meandering bleached", "34": "stylophora alive", "35": "sea urchin", "36": "meandering alive", "37": "meandering dead", "38": "crown of thorn", "39": "dead clam"}
|
87 |
+
label2color = {"unlabeled":[255, 255, 255], "human": [255, 0, 0], "background": [29, 162, 216], "fish": [255, 255, 0], "sand": [194, 178, 128], "rubble": [161, 153, 128], "unknown hard substrate": [125, 125, 125], "algae covered substrate": [125, 163, 125], "dark": [31, 31, 31], "branching bleached": [252, 231, 240], "branching dead": [123, 50, 86], "branching alive": [226, 91, 157], "stylophora alive": [255, 111, 194], "pocillopora alive": [255, 146, 150], "acropora alive": [236, 128, 255], "table acropora alive": [189, 119, 255], "table acropora dead": [85, 53, 116], "millepora": [244, 150, 115], "turbinaria": [228, 255, 119], "other coral bleached": [250, 224, 225], "other coral dead": [114, 60, 61], "other coral alive": [224, 118, 119], "massive/meandering alive": [236, 150, 21], "massive/meandering dead": [134, 86, 18], "massive/meandering bleached": [255, 248, 228], "meandering alive": [230, 193, 0], "meandering dead": [119, 100, 14], "meandering bleached": [251, 243, 216], "transect line": [0, 255, 0], "transect tools": [8, 205, 12], "sea urchin": [0, 142, 255], "sea cucumber": [0, 231, 255], "anemone": [0, 255, 189], "sponge": [240, 80, 80], "clam": [189, 255, 234], "other animal": [0, 255, 255], "trash": [255, 0, 134], "seagrass": [125, 222, 125], "crown of thorn": [179, 245, 234], "dead clam": [89, 155, 134]}
|
88 |
+
id2color = {int(id): label2color[label] for id, label in id2label.items()}
|
89 |
+
|
90 |
+
preprocessor = SegformerImageProcessor.from_pretrained("EPFL-ECEO/segformer-b2-finetuned-coralscapes-1024-1024")
|
91 |
+
model = SegformerForSemanticSegmentation.from_pretrained("EPFL-ECEO/segformer-b2-finetuned-coralscapes-1024-1024")
|
92 |
+
|
93 |
+
inputs = preprocessor(image.resize((1024, 512)), return_tensors = "pt")
|
94 |
+
outputs = model(**inputs)
|
95 |
+
outputs = preprocessor.post_process_semantic_segmentation(outputs, target_sizes=[(image.size[1], image.size[0])])
|
96 |
+
label_pred = outputs[0].cpu().numpy()
|
97 |
+
```
|
98 |
|
99 |
## Training Details
|
100 |
|