时间:2022-06-13 10:13:20 | 栏目:Python代码 | 点击:次
用的pytorch来训练deeplabv3+
在做deeplabv3+的过程中,我的训练图片是8位的,如下图:
8位的:
24位的:
这样虽然在训练过程中能够正常训练。但是在评估过程中会出错,所以决定将训练图片转成24位图,重新训练。最后结果也表明了,只要将训练图片转成24位后之后的评估可视化等都没有问题。
由于RGB的图片就为24位,则简单将图片利用PIL转为RGB格式即可
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Tue Oct 24 10:47:36 2018 @author: yxh """ import numpy as np from PIL import Image import matplotlib.pyplot as plt import os import sys import shutil path='/home/yxh/caffe/examples/fcn/IMAGES/IMAGES/' newpath='/home/yxh/caffe/examples/fcn/IMAGES/output/' def turnto24(path): fileList = [] files = os.listdir(path) i=0 for f in files: imgpath = path + '/' +f img=Image.open(f).convert('RGB') dirpath = newpath file_name, file_extend = os.path.splitext(f) dst = os.path.join(os.path.abspath(dirpath), file_name + '.jpg') img.save(dst) turnto24(path)
总结