Skip to content

Commit efeab72

Browse files
committed
Add dataset description to README
1 parent 8991c14 commit efeab72

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,47 @@ Click the links below to download the checkpoint for the corresponding model typ
9595
* `vit_l`: [ViT-L SAM model.](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth)
9696
* `vit_b`: [ViT-B SAM model.](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth)
9797

98+
## Dataset
99+
See [here](https://ai.facebook.com/datasets/segment-anything/) for an overview of the datastet. The dataset can be downloaded [here](https://ai.facebook.com/datasets/segment-anything-downloads/). By downloading the datasets you agree that you have read and accepted the terms of the SA-1B Dataset Research License.
100+
101+
We save masks per image as a json file. It can be loaded as a dictionary in python in the below format.
102+
103+
104+
```python
105+
{
106+
"image" : image_info,
107+
"annotations" : [annotation],
108+
}
109+
110+
image_info {
111+
"image_id" : int, # Image id
112+
"width" : int, # Image width
113+
"height" : int, # Image height
114+
"file_name" : str, # Image filename
115+
}
116+
117+
annotation {
118+
"id" : int, # Annotation id
119+
"segmentation" : dict, # Mask saved in COCO RLE format.
120+
"bbox" : [x, y, w, h], # The box around the mask, in XYWH format
121+
"area" : int, # The area in pixels of the mask
122+
"predicted_iou" : float, # The model's own prediction of the mask's quality
123+
"stability_score" : float, # A measure of the mask's quality
124+
"crop_box" : [x, y, w, h], # The crop of the image used to generate the mask, in XYWH format
125+
"point_coords" : [[x, y]], # The point coordinates input to the model to generate the mask
126+
}
127+
```
128+
129+
Image ids can be found in sa_images_ids.txt which can be downloaded using the above [link](https://ai.facebook.com/datasets/segment-anything-downloads/) as well.
130+
131+
To decode a mask in COCO RLE format into binary:
132+
```
133+
from pycocotools import mask as mask_utils
134+
mask = mask_utils.decode(annotation["segmentation"])
135+
```
136+
See [here](https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocotools/mask.py) for more instructions to manipulate masks stored in RLE format.
137+
138+
98139
## License
99140
The model is licensed under the [Apache 2.0 license](LICENSE).
100141

0 commit comments

Comments
 (0)