Upload README.md
Browse files
README.md
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- vision
|
5 |
+
- image-segmentatiom
|
6 |
+
|
7 |
+
datasets:
|
8 |
+
- ade-20k
|
9 |
+
|
10 |
+
widget:
|
11 |
+
- src: https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000001.jpg
|
12 |
+
example_title: House
|
13 |
+
- src: https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000002.jpg
|
14 |
+
example_title: Castle
|
15 |
+
|
16 |
+
---
|
17 |
+
|
18 |
+
# Mask
|
19 |
+
|
20 |
+
Mask model trained on ade-20k. It was introduced in the paper [Per-Pixel Classification is Not All You Need for Semantic Segmentation](https://arxiv.org/abs/2107.06278) and first released in [this repository](https://github.com/facebookresearch/MaskFormer/blob/da3e60d85fdeedcb31476b5edd7d328826ce56cc/mask_former/modeling/criterion.py#L169).
|
21 |
+
|
22 |
+
Disclaimer: The team releasing Mask did not write a model card for this model so this model card has been written by the Hugging Face team.
|
23 |
+
|
24 |
+
## Model description
|
25 |
+
|
26 |
+
MaskFormer addresses semantic segmentation with a mask classification paradigm instead.
|
27 |
+
|
28 |
+
![model image](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/maskformer_architecture.png)
|
29 |
+
|
30 |
+
## Intended uses & limitations
|
31 |
+
|
32 |
+
You can use the raw model for image classification. See the [model hub](https://huggingface.co/models?search=maskformer) to look for
|
33 |
+
fine-tuned versions on a task that interests you.
|
34 |
+
|
35 |
+
### How to use
|
36 |
+
|
37 |
+
Here is how to use this model:
|
38 |
+
|
39 |
+
```python
|
40 |
+
>>> from transformers import MaskFormerFeatureExtractor, MaskFormerForInstanceSegmentation
|
41 |
+
>>> from PIL import Image
|
42 |
+
>>> import requests
|
43 |
+
|
44 |
+
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
45 |
+
>>> image = Image.open(requests.get(url, stream=True).raw)
|
46 |
+
>>> feature_extractor = MaskFormerFeatureExtractor.from_pretrained("facebook/maskformer-swin-base-ade")
|
47 |
+
>>> inputs = feature_extractor(images=image, return_tensors="pt")
|
48 |
+
|
49 |
+
>>> model = MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-swin-base-ade")
|
50 |
+
>>> outputs = model(**inputs)
|
51 |
+
>>> # model predicts class_queries_logits of shape `(batch_size, num_queries)`
|
52 |
+
>>> # and masks_queries_logits of shape `(batch_size, num_queries, height, width)`
|
53 |
+
>>> class_queries_logits = outputs.class_queries_logits
|
54 |
+
>>> masks_queries_logits = outputs.masks_queries_logits
|
55 |
+
|
56 |
+
>>> # you can pass them to feature_extractor for postprocessing
|
57 |
+
>>> output = feature_extractor.post_process_segmentation(outputs)
|
58 |
+
>>> output = feature_extractor.post_process_semantic_segmentation(outputs)
|
59 |
+
>>> output = feature_extractor.post_process_panoptic_segmentation(outputs)
|
60 |
+
```
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
For more code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/master/en/model_doc/maskformer).
|