code: def test_small_model_pt(self):
      model_id = "hf-internal-testing/tiny-detr-mobilenetsv3-panoptic"
  
      model = AutoModelForImageSegmentation.from_pretrained(model_id)
      feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
      image_segmenter = ImageSegmentationPipeline(
          model=model,
          feature_extractor=feature_extractor,
          subtask="panoptic",
          threshold=0.0,
          mask_threshold=0.0,
          overlap_mask_area_threshold=0.0,
      )
  
      outputs = image_segmenter(
          "http://images.cocodataset.org/val2017/000000039769.jpg",
      )
  
      # Shortening by hashing
      for o in outputs:
          o["mask"] = mask_to_test_readable(o["mask"])
  
      # This is extremely brittle, and those values are made specific for the CI.
      self.assertEqual(
          nested_simplify(outputs, decimals=4),
          [
              {
                  "score": 0.004,
                  "label": "LABEL_215",
                  "mask": {
                      "hash": "a01498ca7c",
                      "shape": (480, 640),
                      "white_pixels": 307200,
                  },
              },
          ],
      )
  
      outputs = image_segmenter(
          [
              "http://images.cocodataset.org/val2017/000000039769.jpg",
              "http://images.cocodataset.org/val2017/000000039769.jpg",
          ],
      )
      for output in outputs:
          for o in output:
              o["mask"] = mask_to_test_readable(o["mask"])
  
      self.assertEqual(
          nested_simplify(outputs, decimals=4),
          [
              [
                  {
                      "score": 0.004,
                      "label": "LABEL_215",
                      "mask": {
                          "hash": "a01498ca7c",
                          "shape": (480, 640),
                          "white_pixels": 307200,
                      },
                  },
              ],
              [
                  {
                      "score": 0.004,
                      "label": "LABEL_215",
                      "mask": {
                          "hash": "a01498ca7c",
                          "shape": (480, 640),
                          "white_pixels": 307200,
                      },
                  },
              ],
          ],
      )
  
      output = image_segmenter(
          "http://images.cocodataset.org/val2017/000000039769.jpg",
          subtask="instance",
      )
      for o in output:
          o["mask"] = mask_to_test_readable(o["mask"])
      self.assertEqual(
          nested_simplify(output, decimals=4),
          [
              {
                  "score": 0.004,
                  "label": "LABEL_215",
                  "mask": {
                      "hash": "a01498ca7c",
                      "shape": (480, 640),
                      "white_pixels": 307200,
                  },
              },
          ],
      )
  
      # This must be surprising to the reader.
      # The `panoptic` returns only LABEL_215, and this returns 3 labels.
      #
      output = image_segmenter(
          "http://images.cocodataset.org/val2017/000000039769.jpg",
          subtask="semantic",
      )
      for o in output:
          o["mask"] = mask_to_test_readable(o["mask"])
      self.maxDiff = None
      self.assertEqual(
          nested_simplify(output, decimals=4),
          [
              {
                  "label": "LABEL_88",
                  "mask": {
                      "hash": "7f0bf661a4",
                      "shape": (480, 640),
                      "white_pixels": 3,
                  },
                  "score": None,
              },
              {
                  "label": "LABEL_101",
                  "mask": {
                      "hash": "10ab738dc9",
                      "shape": (480, 640),
                      "white_pixels": 8948,
                  },
                  "score": None,
              },
              {
                  "label": "LABEL_215",
                  "mask": {
                      "hash": "b431e0946c",
                      "shape": (480, 640),
                      "white_pixels": 298249,
                  },
                  "score": None,
              },
          ],
      )
  
imports: import hashlib
  import unittest
  from typing import Dict
  import datasets
  import numpy
  from datasets import load_dataset
  from transformers import MODEL_FOR_IMAGE_SEGMENTATION_MAPPING, MODEL_FOR_INSTANCE_SEGMENTATION_MAPPING, MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING, AutoFeatureExtractor, AutoModelForImageSegmentation, AutoModelForInstanceSegmentation, DetrForSegmentation, ImageSegmentationPipeline, MaskFormerForInstanceSegmentation, is_vision_available, pipeline
  from transformers.testing_utils import nested_simplify, require_tf, require_timm, require_torch, require_vision, slow
  from .test_pipelines_common import ANY, PipelineTestCaseMeta
label_desc: Use image node_id 5 for calling the ImageSegmentationPipelineTests obj's underlying member method code with example usage: obj.test_small_model_pt() without return types