1 Star 2 Fork 0

WZY99/医学骨骼分割

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
callback.py 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
WZY99 提交于 2021-04-25 11:19 . 添加随机种子,加入回调函数
import paddle
import cv2
import numpy as np
from dataset import TestDataset
import config
class StepTest(paddle.callbacks.Callback):
def __init__(self):
self.testdataset = TestDataset('test')
def on_train_batch_end(self, step, logs=None):
outs = self.model.predict(self.testdataset)
outs = outs[0]
for index, out in enumerate(outs):
path = self.testdataset.indexs[index]
img = cv2.imread(path)
# # 输出热力图
# res = np.reshape(out, (config.LABLE_SIZE, config.LABLE_SIZE, config.CLASS_NUMBER))
# lab = (np.argmax(res, axis=-1) / config.CLASS_NUMBER * 255).astype(np.uint8)
# color = cv2.applyColorMap(lab, cv2.COLORMAP_JET)
# cv2.imwrite('result/' + str(index) + 'result.jpg', color)
# 输出每张图
res = np.reshape(out, (config.LABLE_SIZE, config.LABLE_SIZE, config.CLASS_NUMBER))
res = res * 254
res = res.astype(np.uint8)
# for ch in range(config.CLASS_NUMBER):
# r = res[:, :, ch]
# lab = config.ID2LABEL[ch]
# cv2.imwrite('step_log/' + str(step) + 'result' + lab + '.jpg', r)
ch = 1
r = res[:, :, ch]
lab = config.ID2LABEL[ch]
cv2.imwrite('step_log/' + str(step) + 'result' + lab + '.jpg', r)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wzy-99/medical-bone-segmentation.git
git@gitee.com:wzy-99/medical-bone-segmentation.git
wzy-99
medical-bone-segmentation
医学骨骼分割
master

搜索帮助