run04_model_inference.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:FCN_MSCOCO_Food_Segmentation 作者: gakarak 项目源码 文件源码
def readDataMasked(pidx):
    with open(pidx, 'r') as f:
        wdir = os.path.dirname(pidx)
        lstpath = f.read().splitlines()
        lstpath = [os.path.join(wdir,xx) for xx in lstpath]
        numPath = len(lstpath)
        dataX = None
        dataY = None
        for ii,pp in enumerate(lstpath):
            img4 = skio.imread(pp)
            img = img4[:,:,:3].astype(np.float)
            img -= img.mean()
            img /= img.std()
            msk = (img4[:,:,3]>0).astype(np.float)
            msk = np_utils.to_categorical(msk.reshape(-1), 2)
            # msk = msk.reshape(-1)
            if dataX is None:
                dataX = np.zeros([numPath] + list(img.shape))
                dataY = np.zeros([numPath] + list(msk.shape))
            dataX[ii] = img
            dataY[ii] = msk
            if (ii%100)==0:
                print ('[%d/%d]' % (ii, numPath))
        return (dataX, dataY)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号