How to separate predictions map to create id2label.json

@John6666 Okay so I get these

and this

[{'score': None,
  'label': 'wall',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'building',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'sky',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'tree',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'mountain',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'water',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'fence',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'rock',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'signboard',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'bridge',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'boat',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>},
 {'score': None,
  'label': 'pier',
  'mask': <PIL.Image.Image image mode=L size=1080x1080>}]

Is this what I move to here?


import datasets
import glob

IMAGES = glob.glob("D:\cropped_image_1080x1080\img_0")
SEG_MAPS = glob.glob("D:.\img_0.jpg")

dataset = datasets.Dataset.from_dict({
    "image": IMAGES,
    "label": SEG_MAPS
},
features=datasets.Features({
    "image":datasets.Image(),
    "label":datasets.Image()
                            })
)

I still don’t get how I move the fifth member of this pipeline that I got from here

from transformers import pipeline

semantic_segmentation = pipeline("image-segmentation", "shi-labs/oneformer_ade20k_swin_large")

to id2label, do I need to label it as implied in here?

1 Like