nielsr HF staff commited on
Commit
0358c67
1 Parent(s): 19af8bb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -20
README.md CHANGED
@@ -1,10 +1,15 @@
1
  ---
2
- license: apache-2.0
3
  tags:
4
  - vision
5
  - image-segmentation
6
  datasets:
7
- - ade-20k
 
 
 
 
 
8
  ---
9
 
10
  # MaskFormer
@@ -29,24 +34,24 @@ fine-tuned versions on a task that interests you.
29
  Here is how to use this model:
30
 
31
  ```python
32
- >>> from transformers import MaskFormerFeatureExtractor, MaskFormerForInstanceSegmentation
33
- >>> from PIL import Image
34
- >>> import requests
35
-
36
- >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
37
- >>> image = Image.open(requests.get(url, stream=True).raw)
38
- >>> feature_extractor = MaskFormerFeatureExtractor.from_pretrained("facebook/maskformer-swin-base-ade")
39
- >>> inputs = feature_extractor(images=image, return_tensors="pt")
40
-
41
- >>> model = MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-swin-base-ade")
42
- >>> outputs = model(**inputs)
43
- >>> # model predicts class_queries_logits of shape `(batch_size, num_queries)`
44
- >>> # and masks_queries_logits of shape `(batch_size, num_queries, height, width)`
45
- >>> class_queries_logits = outputs.class_queries_logits
46
- >>> masks_queries_logits = outputs.masks_queries_logits
47
-
48
- >>> # you can pass them to feature_extractor for postprocessing
49
- >>> predicted_semantic_map = feature_extractor.post_process_semantic_segmentation(outputs)[0]
50
  ```
51
 
52
  For more code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/master/en/model_doc/maskformer).
 
1
  ---
2
+ license: other
3
  tags:
4
  - vision
5
  - image-segmentation
6
  datasets:
7
+ - scene_parse_150
8
+ widget:
9
+ - src: https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000001.jpg
10
+ example_title: House
11
+ - src: https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000002.jpg
12
+ example_title: Castle
13
  ---
14
 
15
  # MaskFormer
 
34
  Here is how to use this model:
35
 
36
  ```python
37
+ from transformers import MaskFormerFeatureExtractor, MaskFormerForInstanceSegmentation
38
+ from PIL import Image
39
+ import requests
40
+
41
+ url = "https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000001.jpg"
42
+ image = Image.open(requests.get(url, stream=True).raw)
43
+ feature_extractor = MaskFormerFeatureExtractor.from_pretrained("facebook/maskformer-swin-base-ade")
44
+ inputs = feature_extractor(images=image, return_tensors="pt")
45
+
46
+ model = MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-swin-base-ade")
47
+ outputs = model(**inputs)
48
+ # model predicts class_queries_logits of shape `(batch_size, num_queries)`
49
+ # and masks_queries_logits of shape `(batch_size, num_queries, height, width)`
50
+ class_queries_logits = outputs.class_queries_logits
51
+ masks_queries_logits = outputs.masks_queries_logits
52
+
53
+ # you can pass them to feature_extractor for postprocessing
54
+ predicted_semantic_map = feature_extractor.post_process_semantic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]
55
  ```
56
 
57
  For more code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/master/en/model_doc/maskformer).