参考一篇keras实现unet的文章,将其复现,但效果很差!
- 读取.mat文件,并将矩阵保存为图片(0-255)
root = "./cls/"
contours_dir = "./contours/"
for rt, dirs, files in os.walk(root):
print len(files)
for f in files:
matfile = f
filename = matfile.split('.')[0]
dataFile = root + matfile # inst
data = scio.loadmat(dataFile)
arr = np.array(data['GTcls'][0][0][1], dtype=np.uint8)*255
cv2.imwrite(contours_dir + filename+".jpg",arr)
- 生成目录描述文件
$find pos -name *.jpg > _pos.txt
- 文件操作,遍历、读取每行 ;img/2008_007928.jpg ,注意有换行符
train_files = []
with open("dataset/img_txt.txt",'r') as f_train:
files = f_train.readlines()
for name in files:
if len(name) < 20: #跳过不完整的描述文件
continue
name = name.split("/")[1].split("\n")[0]
train_files.append(name)
- skimage、opencv
skimage
RGB [0,1] (float)
Opencv
BGR [0,255]
$sudo pip install scikit-image
安装顺序:nvida驱动 、cuda(注意驱动版本)、cudnn(注意cuda版本)
Tensorflow不同版本要求与CUDA及CUDNN版本对应关系
https://blog.csdn.net/omodao1/article/details/83241074