• 大小: 6KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-16
  • 语言: 其他
  • 标签: SDB  Tools  

资源简介

本来想设置成免费的,可惜资源分竟然设置不了免费,抱歉了各位。这个是pascal voc语义分割任务中增强的sbd使用的一些脚本

资源截图

代码片段和文件信息

#!/usr/bin/env python
# Martin Kersner m.kersner@gmail.com
# 2016/01/25 

from __future__ import print_function
import os
import sys
from skimage.io import imread imsave
from utils import convert_from_color_segmentation
import numpy as np

def main():
  ##
  ext = ‘.png‘
  ##

  path txt_file path_converted = process_arguments(sys.argv)

  # Create dir for converted labels
  if not os.path.isdir(path_converted):
    os.makedirs(path_converted)

  with open(txt_file ‘rb‘) as f:
    for img_name in f:
      img_base_name = img_name.strip()
      img_name = os.path.join(path img_base_name) + ext
      img = imread(img_name)

      if (len(img.shape) > 2):
        img = convert_from_color_segmentation(img)
        imsave(os.path.join(path_converted img_base_name) + ext img)
      else:
        print(img_name + “ is not composed of three dimensions therefore “ 
              “shouldn‘t be processed by this script.\n“
              “Exiting.“  file=sys.stderr)

        exit()

def process_arguments(argv):
  if len(argv) != 4:
    help()

  path = argv[1]
  list_file = argv[2]
  new_path = argv[3]

  return path list_file new_path 

def help():
  print(‘Usage: python convert_labels.py PATH LIST_FILE NEW_PATH\n‘
        ‘PATH points to directory with segmentation image labels.\n‘
        ‘LIST_FILE denotes text file containing names of images in PATH.\n‘
        ‘Names do not include extension of images.\n‘
        ‘NEW_PATH points to directory where converted labels will be stored.‘
         file=sys.stderr)
  
  exit()

if __name__ == ‘__main__‘:
  main()


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-03-22 14:12  tools\
     文件        3707  2018-01-30 14:25  tools\utils.py
     文件        1590  2018-01-30 14:20  tools\convert_labels.py
     文件        5813  2018-01-30 14:26  tools\utils.pyc
     文件        1664  2018-03-22 14:12  tools\mat2png.py

评论

共有 条评论