code: def uwmgi_to_multilabel_format(args):
      with zipfile.ZipFile(args.zip_input, "r") as zip_fp:
          total_df = pd.read_csv(zip_fp.open("train.csv", "r"))
  
          total_image_namelist = []
          for name in zip_fp.namelist():
              if os.path.splitext(name)[1] == ".png":
                  total_image_namelist.append(name)
          train_image_namelist = random.sample(
              total_image_namelist,
              int(len(total_image_namelist) * args.train_proportion),
          )
          val_image_namelist = np.setdiff1d(
              total_image_namelist, train_image_namelist
          )
  
          pbar = tqdm(total=len(total_image_namelist))
          for image_namelist, split in zip(
              [train_image_namelist, val_image_namelist],
              ["train", "val"],
          ):
              txt_lines = []
              for image_name in image_namelist:
                  with zip_fp.open(image_name, "r") as fp:
                      image = uwmgi_get_image(fp)
                      image_id = uwmgi_get_image_id(image_name)
                      anns = total_df[total_df["id"] == image_id]
                      height, width = image.shape[:2]
                      mask = np.zeros(
                          [height, width * 3], dtype="uint8"
                      )
                      for _, ann in anns.iterrows():
                          if not pd.isna(ann["segmentation"]):
                              if ann["class"] == "large_bowel":
                                  mask[:, 0:width] = uwmgi_rle_decode(
                                      ann["segmentation"],
                                      (height, width),
                                  )
                              elif ann["class"] == "small_bowel":
                                  mask[
                                      :, width : width * 2
                                  ] = uwmgi_rle_decode(
                                      ann["segmentation"],
                                      (height, width),
                                  )
                              else:  # ann['class'] == 'stomach'
                                  mask[
                                      :, width * 2 :
                                  ] = uwmgi_rle_decode(
                                      ann["segmentation"],
                                      (height, width),
                                  )
                      cv2.imwrite(
                          os.path.join(
                              args.output,
                              "images",
                              split,
                              image_id + ".jpg",
                          ),
                          image,
                      )
                      cv2.imwrite(
                          os.path.join(
                              args.output,
                              "annotations",
                              split,
                              image_id + ".png",
                          ),
                          mask,
                      )
                      txt_lines.append(
                          os.path.join(
                              "images", split, image_id + ".jpg"
                          )
                          + " "
                          + os.path.join(
                              "annotations", split, image_id + ".png"
                          )
                      )
                      pbar.update()
  
              with open(
                  os.path.join(args.output, split + ".txt"), "w"
              ) as fp:
                  fp.write("\n".join(txt_lines))
  
file_path: PaddleSeg/tools/data/convert_multilabel.py
imports: import argparse
  import os
  import random
  import zipfile
  import cv2
  import numpy
  import pandas
  from PIL import Image
  from pycocotools.coco import COCO
  from tqdm import tqdm
label_desc: Use image node_id 4 for calling a global function with example usage: uwmgi_to_multilabel_format(args) without return types