File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/transformers/pipelines Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,30 @@ class ImageSegmentationPipeline(Pipeline):
3232 Image segmentation pipeline using any `AutoModelForXXXSegmentation`. This pipeline predicts masks of objects and
3333 their classes.
3434
35+ Example:
36+
37+ ```python
38+ >>> from transformers import pipeline
39+
40+ >>> segmenter = pipeline(model="facebook/detr-resnet-50-panoptic")
41+ >>> segments = segmenter("https://huggingface.co/datasets/Narsil/image_dummy/raw/main/parrots.png")
42+ >>> len(segments)
43+ 2
44+
45+ >>> segments[0]["label"]
46+ 'bird'
47+
48+ >>> segments[1]["label"]
49+ 'bird'
50+
51+ >>> type(segments[0]["mask"]) # This is a black and white mask showing where is the bird on the original image.
52+ <class 'PIL.Image.Image'>
53+
54+ >>> segments[0]["mask"].size
55+ (768, 512)
56+ ```
57+
58+
3559 This image segmentation pipeline can currently be loaded from [`pipeline`] using the following task identifier:
3660 `"image-segmentation"`.
3761
You can’t perform that action at this time.
0 commit comments