praeclarumjj3 commited on
Commit
bbad99a
1 Parent(s): 8209f6c

Add OneFormerProcessor

Browse files
Files changed (1) hide show
  1. README.md +8 -8
README.md CHANGED
@@ -36,33 +36,33 @@ You can use this particular checkpoint for semantic, instance and panoptic segme
36
  Here is how to use this model:
37
 
38
  ```python
39
- from transformers import OneFormerImageProcessor, OneFormerForUniversalSegmentation
40
  from PIL import Image
41
  import requests
42
  url = "https://huggingface.co/datasets/shi-labs/oneformer_demo/blob/main/ade20k.jpeg"
43
  image = Image.open(requests.get(url, stream=True).raw)
44
 
45
  # Loading a single model for all three tasks
46
- image_processor = OneFormerImageProcessor.from_pretrained("shi-labs/oneformer_ade20k_swin_large")
47
  model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/oneformer_ade20k_swin_large")
48
 
49
  # Semantic Segmentation
50
- semantic_inputs = image_processor(images=image, ["semantic"] return_tensors="pt")
51
  semantic_outputs = model(**semantic_inputs)
52
  # pass through image_processor for postprocessing
53
- predicted_semantic_map = image_processor.post_process_semantic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]
54
 
55
  # Instance Segmentation
56
- instance_inputs = image_processor(images=image, ["instance"] return_tensors="pt")
57
  instance_outputs = model(**instance_inputs)
58
  # pass through image_processor for postprocessing
59
- predicted_instance_map = image_processor.post_process_instance_segmentation(outputs, target_sizes=[image.size[::-1]])[0]["segmentation"]
60
 
61
  # Panoptic Segmentation
62
- panoptic_inputs = image_processor(images=image, ["panoptic"] return_tensors="pt")
63
  panoptic_outputs = model(**panoptic_inputs)
64
  # pass through image_processor for postprocessing
65
- predicted_semantic_map = image_processor.post_process_panoptic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]["segmentation"]
66
  ```
67
 
68
  For more examples, please refer to the [documentation](https://huggingface.co/docs/transformers/master/en/model_doc/oneformer).
 
36
  Here is how to use this model:
37
 
38
  ```python
39
+ from transformers import OneFormerProcessor, OneFormerForUniversalSegmentation
40
  from PIL import Image
41
  import requests
42
  url = "https://huggingface.co/datasets/shi-labs/oneformer_demo/blob/main/ade20k.jpeg"
43
  image = Image.open(requests.get(url, stream=True).raw)
44
 
45
  # Loading a single model for all three tasks
46
+ processor = OneFormerProcessor.from_pretrained("shi-labs/oneformer_ade20k_swin_large")
47
  model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/oneformer_ade20k_swin_large")
48
 
49
  # Semantic Segmentation
50
+ semantic_inputs = processor(images=image, ["semantic"] return_tensors="pt")
51
  semantic_outputs = model(**semantic_inputs)
52
  # pass through image_processor for postprocessing
53
+ predicted_semantic_map = processor.post_process_semantic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]
54
 
55
  # Instance Segmentation
56
+ instance_inputs = processor(images=image, ["instance"] return_tensors="pt")
57
  instance_outputs = model(**instance_inputs)
58
  # pass through image_processor for postprocessing
59
+ predicted_instance_map = processor.post_process_instance_segmentation(outputs, target_sizes=[image.size[::-1]])[0]["segmentation"]
60
 
61
  # Panoptic Segmentation
62
+ panoptic_inputs = processor(images=image, ["panoptic"] return_tensors="pt")
63
  panoptic_outputs = model(**panoptic_inputs)
64
  # pass through image_processor for postprocessing
65
+ predicted_semantic_map = processor.post_process_panoptic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]["segmentation"]
66
  ```
67
 
68
  For more examples, please refer to the [documentation](https://huggingface.co/docs/transformers/master/en/model_doc/oneformer).