資源簡介
本來想設置成免費的,可惜資源分竟然設置不了免費,抱歉了各位。這個是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
- 上一篇:文本統計工具
- 下一篇:stm32f427工程demo
評論
共有 條評論