m0_51422996 2022-11-22 16:22 采纳率: 58.3%
浏览 7
已结题

如何用代码块功能插入代码?

问题遇到的现象和发生背景

预测运行报错

用代码块功能插入代码,请勿粘贴截图

def predict(dataset,model):

# unet = torch.load('./core/0.5unet.pkl').to(device)
# torch.save(unet.state_dict(), "model_new.pth")

global res, img_y, mask_arrary
with torch.no_grad():
    x = dataset[0][0].to(device)
    file_name = dataset[1]
    y = model(x)
    img_y = torch.squeeze(y).cpu().numpy()
    img_y[img_y >= rate] = 1
    img_y[img_y < rate] = 0
    img_y = img_y * 255
    cv2.imwrite(f'./tmp/mask/{file_name}_mask.png', img_y,
                (cv2.IMWRITE_PNG_COMPRESSION, 0))
运行结果及报错内容

File "D:\Users\Administrator\PycharmProjects\CTAI-master\CTAI_flask\core\predict.py", line 27, in predict
y = model(x)
TypeError: 'NoneType' object is not callable

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 11月30日
    • 创建了问题 11月22日

    悬赏问题

    • ¥50 树莓派安卓APK系统签名
    • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗