iulia-elisa
commited on
Commit
•
7182881
1
Parent(s):
ffd795a
Update README.md
Browse files
README.md
CHANGED
@@ -17,4 +17,152 @@ datasets:
|
|
17 |
<h1> XAMI-model: XMM-Newton optical Artefact Mapping for astronomical Instance segmentation </h1>
|
18 |
</div>
|
19 |
|
20 |
-
This repository contains the weights of the **[XAMI model](https://github.com/ESA-Datalabs/XAMI-model)**. The model is trained on images from the XAMI dataset (available on Github and HuggingFace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
<h1> XAMI-model: XMM-Newton optical Artefact Mapping for astronomical Instance segmentation </h1>
|
18 |
</div>
|
19 |
|
20 |
+
This repository contains the weights of the **[XAMI model](https://github.com/ESA-Datalabs/XAMI-model)**. The model is trained on images from the XAMI dataset (available on Github and HuggingFace). The images are astronomical observations from the Optical Monitor (XMM-OM) onboard the XMM-Newton X-ray mission.
|
21 |
+
|
22 |
+
Information about the XMM-OM can be found here:
|
23 |
+
|
24 |
+
- [The ESA website](https://www.cosmos.esa.int/web/xmm-newton/technical-details-om)
|
25 |
+
- [The article *The XMM-Newton optical/UV monitor telescope*](https://ui.adsabs.harvard.edu/abs/2001A%26A...365L..36M/abstract).
|
26 |
+
|
27 |
+
<p align="center">
|
28 |
+
<img src="https://github.com/ESA-Datalabs/XAMI-model/blob/main/example_images/xami_model.png" alt="The XAMI model combining a detector and segmentor, while freezing the detector model previously trained on the XAMI dataset." width="40%">
|
29 |
+
</p>
|
30 |
+
|
31 |
+
<p align="center">
|
32 |
+
<em>Figure 1: The XAMI model combining a detector and segmentor, while freezing the detector model previously trained on the XAMI dataset.</em>
|
33 |
+
</p>
|
34 |
+
|
35 |
+
## Cloning the repository
|
36 |
+
|
37 |
+
```bash
|
38 |
+
git clone https://github.com/ESA-Datalabs/XAMI-model.git
|
39 |
+
cd XAMI-model
|
40 |
+
|
41 |
+
# creating the environment
|
42 |
+
conda env create -f environment.yaml
|
43 |
+
conda activate xami_model_env
|
44 |
+
|
45 |
+
# Install the package in editable mode
|
46 |
+
pip install -e .
|
47 |
+
```
|
48 |
+
|
49 |
+
## Downloading the dataset and model checkpoints from HuggingFace
|
50 |
+
|
51 |
+
The dataset is splited into train and validation categories and contains annotated artefacts in COCO format for Instance Segmentation. We use multilabel Stratified K-fold (k=4) to balance class distributions across splits. We choose to work with a single dataset splits version (out of 4) but also provide means to work with all 4 versions.
|
52 |
+
|
53 |
+
The [Dataset-Structure.md](https://github.com/ESA-Datalabs/XAMI-dataset/blob/main/Datasets-Structure.md) offers more details about the dataset structure. We provide the following dataset formats: COCO format for Instance Segmentation (commonly used by [Detectron2](https://github.com/facebookresearch/detectron2) models) and YOLOv8-Seg format used by [ultralytics](https://github.com/ultralytics/ultralytics).
|
54 |
+
|
55 |
+
<!-- 1. **Downloading** the dataset archive from [HuggingFace](https://huggingface.co/datasets/iulia-elisa/XAMI-dataset/blob/main/xami_dataset.zip).
|
56 |
+
|
57 |
+
```bash
|
58 |
+
DEST_DIR='.' # destination folder for the dataset (should usually be set to current directory)
|
59 |
+
|
60 |
+
huggingface-cli download iulia-elisa/XAMI-dataset xami_dataset.zip --repo-type dataset --local-dir "$DEST_DIR" && unzip "$DEST_DIR/xami_dataset.zip" -d "$DEST_DIR" && rm "$DEST_DIR/xami_dataset.zip"
|
61 |
+
``` -->
|
62 |
+
|
63 |
+
|
64 |
+
Check the [dataset_and_model.ipynb](https://github.com/ESA-Datalabs/XAMI-model/blob/main/dataset_and_model.ipynb) for downloading the dataset and model weights.
|
65 |
+
|
66 |
+
## Model Inference
|
67 |
+
|
68 |
+
After cloning the repository and setting up the environment, use the following code for model loading and inference:
|
69 |
+
|
70 |
+
```python
|
71 |
+
from xami_model.inference.xami_inference import InferXami
|
72 |
+
|
73 |
+
det_type = 'rtdetr' # 'rtdetr' 'yolov8'
|
74 |
+
|
75 |
+
detr_checkpoint = f'./xami_model/train/weights/{det_type}_sam_weights/{det_type}_detect_300e_best.pt'
|
76 |
+
sam_checkpoint = f'./xami_model/train/weights/{det_type}_sam_weights/{det_type}_sam.pth'
|
77 |
+
|
78 |
+
detr_sam_pipeline = InferXami(
|
79 |
+
device='cuda:0',
|
80 |
+
detr_checkpoint=detr_checkpoint,
|
81 |
+
sam_checkpoint=sam_checkpoint,
|
82 |
+
model_type='vit_t', # the SAM checkpoint and model_type (vit_h, vit_t, etc.) must be compatible
|
83 |
+
use_detr_masks=True,
|
84 |
+
detr_type=det_type)
|
85 |
+
|
86 |
+
masks = detr_sam_pipeline.run_predict('./example_images/S0893811101_M.png', show_masks=True)
|
87 |
+
```
|
88 |
+
|
89 |
+
For training the model, check the training [README.md](https://github.com/ESA-Datalabs/XAMI-model/blob/main/xami_model/train/README.md).
|
90 |
+
|
91 |
+
## Performance metrics
|
92 |
+
|
93 |
+
<p align="center">
|
94 |
+
<img src="https://github.com/ESA-Datalabs/XAMI-model/blob/main/example_images/ious_rtdetr.png" alt="Cumulative distribution of IoUs between predicted and true masks using RT-DETR as detector." width="70%">
|
95 |
+
</p>
|
96 |
+
<p align="center">
|
97 |
+
<em>Figure 2: Cumulative distribution of IoUs between predicted and true masks using RT-DETR as detector.</em>
|
98 |
+
</p>
|
99 |
+
|
100 |
+
<div align="center">
|
101 |
+
<table style="width: 100%; border-collapse: collapse; text-align: center;">
|
102 |
+
<thead>
|
103 |
+
<tr>
|
104 |
+
<th rowspan="2">Category</th>
|
105 |
+
<th colspan="2">Precision</th>
|
106 |
+
<th colspan="2">Recall</th>
|
107 |
+
</tr>
|
108 |
+
<tr>
|
109 |
+
<th>YOLO-v8</th>
|
110 |
+
<th>RT-DETR</th>
|
111 |
+
<th>YOLO-v8</th>
|
112 |
+
<th>RT-DETR</th>
|
113 |
+
</tr>
|
114 |
+
</thead>
|
115 |
+
<tbody>
|
116 |
+
<tr>
|
117 |
+
<td><b>Overall</b></td>
|
118 |
+
<td><b>84.3</b></td>
|
119 |
+
<td><b>62.7</b></td>
|
120 |
+
<td><b>72.1</b></td>
|
121 |
+
<td><b>78.3</b></td>
|
122 |
+
</tr>
|
123 |
+
<tr>
|
124 |
+
<td>Central-Ring</td>
|
125 |
+
<td>89.3</td>
|
126 |
+
<td>89.1</td>
|
127 |
+
<td>94.0</td>
|
128 |
+
<td>97.0</td>
|
129 |
+
</tr>
|
130 |
+
<tr>
|
131 |
+
<td>Read-out-Streak</td>
|
132 |
+
<td>71.1</td>
|
133 |
+
<td>68.3</td>
|
134 |
+
<td>73.3</td>
|
135 |
+
<td>95.3</td>
|
136 |
+
</tr>
|
137 |
+
<tr>
|
138 |
+
<td>Smoke-Ring</td>
|
139 |
+
<td>80.6</td>
|
140 |
+
<td>78.1</td>
|
141 |
+
<td>85.6</td>
|
142 |
+
<td>93.8</td>
|
143 |
+
</tr>
|
144 |
+
<tr>
|
145 |
+
<td>Star-Loop</td>
|
146 |
+
<td>80.5</td>
|
147 |
+
<td>71.6</td>
|
148 |
+
<td>74.1</td>
|
149 |
+
<td>83.3</td>
|
150 |
+
</tr>
|
151 |
+
<tr>
|
152 |
+
<td><i>Other</i></td>
|
153 |
+
<td>100.0</td>
|
154 |
+
<td>6.2</td>
|
155 |
+
<td>33.3</td>
|
156 |
+
<td>22.2</td>
|
157 |
+
</tr>
|
158 |
+
</tbody>
|
159 |
+
</table>
|
160 |
+
</div>
|
161 |
+
|
162 |
+
<p align="center">
|
163 |
+
<em>Table 1: Metrics per object detector used.</em>
|
164 |
+
</p>
|
165 |
+
|
166 |
+
## © Licence
|
167 |
+
|
168 |
+
This project is licensed under [MIT license](LICENSE).
|