module 'numpy' has no attribute 'bool'

问题:

Traceback (most recent call last):
File "/home/test.py", line 138, in <module>
inference(args, net, test_save_path)
File "/home/test.py", line 54, in inference
metric_i = test_single_volume(image, label, model, classes=args.num_classes, patch_size=[args.img_size, args.img_size],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/utils.py", line 90, in test_single_volume
metric_list.append(calculate_metric_percase(prediction == i, label == i))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/utils.py", line 52, in calculate_metric_percase
dice = metric.binary.dc(pred, gt)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/anaconda3/envs/python311/lib/python3.11/site-packages/medpy/metric/binary.py", line 68, in dc
result = numpy.atleast_1d(result.astype(numpy.bool))
^^^^^^^^^^
File "/home/anaconda3/envs/python311/lib/python3.11/site-packages/numpy/__init__.py", line 324, in __getattr__
raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?

原因:

不推荐使用np.boolnp.int等内置类型。在Numpy1.24.0 中不推荐的类型已经完全移除。当使用旧版本的时候就会出现这个问题。

解决:

使用未移除前的版本诸如numpy==1.23.2

pip install numpy==1.23.2

module 'numpy' has no attribute 'bool'的更多相关文章

  1. 【Python 数据分析】module 'numpy' has no attribute 'array'

    安装好Numpy模块后,开始做了几个小测试都可以运行,但是当我创建numpy.py这个文件后 numpy.py import numpy y = numpy.array([[11,4,2],[2,6, ...

  2. Pytorch:module 'torch' has no attribute 'bool'

    Pytorch:module 'torch' has no attribute 'bool' 这个应该是有些版本的Pytorch会遇到这个问题,我用0.4.0版本测试发现torch.bool是有的,但 ...

  3. AttributeError: module 'numpy' has no attribute 'num'

    AttributeError: module 'numpy' has no attribute 'num' 写在前面 总的来说,先看看自己用的计算方式是不是写对了先,多个一起使用的话记得都看看 通过想 ...

  4. Python基础学习-'module' object has no attribute 'urlopen'解决方法

    import numpy as npimport urlliburl = "http://archive.ics.uci.edu/ml/machine-learning-databases/ ...

  5. 解决:pipenv shell报错:AttributeError: 'module' object has no attribute 'run'

    利用pipenv shell切换到虚拟环境时,显示报错:AttributeError: 'module' object has no attribute 'run' 可以看到是d:\program\p ...

  6. module 'cv2' has no attribute 'KNearest_create'

    python版本:3.6.5 opencv版本:3.2.0 使用的是jupyter notebook 源代码如下: import cv2 import numpy as np import matpl ...

  7. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  8. Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  9. attributeError:'module' object has no attribute ** 解决办法

    写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...

  10. AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'

    /*************************************************************************** * AttributeError: 'modu ...

随机推荐

  1. NC16645 [NOIP2007]矩阵取数游戏

    题目链接 题目 题目描述 帅帅经常跟同学玩一个矩阵取数游戏:对于一个给定的n*m的矩阵,矩阵中的每个元素aij均为非负整数.游戏规则如下: 1.每次取数时须从每行各取走一个元素,共n个.m次后取完矩阵 ...

  2. ARM 中常用的汇编指令解释汇总

    前言 嵌入式项目中经常涉及到需要通过分析编译后的汇编文件,来确定异常代码,对一些常用的指令进行了汇总. 一.处理器内部数据传输指令 在ARM架构中,包括Cortex-A7处理器内部,有一些专门用于数据 ...

  3. Linux进程的创建与销毁

    Linux操作系统是一种多任务.多用户的操作系统,这意味着它可以同时运行多个进程,每个进程都可以执行不同的任务. 在本文中,我们将介绍如何在Linux系统中创建和销毁进程. 进程的创建 在Linux系 ...

  4. 使用V2R做反向代理内网穿透

    环境 内网服务器Prob1位于内网LAN1, 内网服务器Prob2位于内网LAN2, 外网服务器Serv1位于IP 123.123.123.123 内网节点配置 内网节点没有inbound,只需要配置 ...

  5. 【framework】AMS启动流程

    1 前言 ​ AMS 即 ActivityManagerService,负责 Activy.Service.Broadcast.ContentProvider 四大组件的生命周期管理.本文主要介绍 A ...

  6. React闭包陷阱

    React闭包陷阱 React Hooks是React 16.8引入的一个新特性,其出现让React的函数组件也能够拥有状态和生命周期方法,其优势在于可以让我们在不编写类组件的情况下,更细粒度地复用状 ...

  7. Swoole从入门到入土(26)——多进程[进程间锁]

    多进程在Swoole中是一个很重要的话题,即是协程机制也是依赖于进程.所以Swoole\Lock让大家在PHP 代码中可以很方便地创建一个锁,用来实现数据同步.Lock 类支持以下 5 种锁的类型: ...

  8. Mybatis-Plus自动生成代码的CodeGenerator代码

    官方地址:Mybatis-Plus:https://mp.baomidou.com/guide/generator.html pom中导入mybatis plus的jar包,因为后面会涉及到代码生成, ...

  9. OpenCV开发笔记(五十八):红胖子8分钟带你深入了解图像的矩(图文并茂+浅显易懂+程序源码)

    若该文为原创文章,未经允许不得转载原博主博客地址:https://blog.csdn.net/qq21497936原博主博客导航:https://blog.csdn.net/qq21497936/ar ...

  10. Qt实用技巧:Qt从QtCreator更换为VS开发Qt所需要注意的坑

    前言   基本都是使用QtCreator开发,使用vs进行一下开发,记录从QtCreator换成VS所遇到的注意的坑.   VS装对应的Qt版本助手配置Qt版本        VS装番茄助手   这里 ...