当前位置:网站首页>解决glob()返回文件排序不一致问题&onnx本地按照安装方法
解决glob()返回文件排序不一致问题&onnx本地按照安装方法
2022-08-02 03:21:00 【& Tom】
0.问题背景
将服务器RTX2080Ti上的数据迁移至自己电脑RTX3060上,一样的代码,一个是Ubuntu20.04,一个是18.04,各种软件包版本均相同。
问题:训练时损失基本是常数,变化不大,计算出来的mIoU是一个常数,没有变化,上次遇到这个问题是由于标签的问题,这次已经处理好了又出现了问题,会是哪里的问题呢?
1.寻找解决办法
半夜在Debug的时候,一步一步Debug,发现在加载数据集的时候,用到了以下代码:
self.train_img_paths = glob(self.root + r"/image/training/*")
self.train_mask_paths = glob(self.root + r"/annotation/training/*")
self.val_img_paths = glob(self.root + r"/images/test/*")
self.val_mask_paths = glob(self.root + r"/annotations/test/*")在服务器上使用,可以正常使用,在本地电脑上却出现以下问题:

可以看出,img路径和mask路径出现不对应,这也不可能正确学习到东西阿!
2.解决方法
可以看出,出现以上问题的原因基本就是因为图片和标签不对应而造成的,解决方法就是对glob到的文件按照一定的规律排序,使图像和标签对应即可。加入sorted()排序后的文件顺序如图,这下标签和图像基本对应起来了。调试以下,也一切正常了。
self.train_img_paths = sorted(glob(self.root + r"/image/training/*"))
self.train_mask_paths = sorted(glob(self.root + r"/annotation/training/*"))
self.val_img_paths = sorted(glob(self.root + r"/images/test/*"))
self.val_mask_paths = sorted(glob(self.root + r"/annotations/test/*"))
顺序正常了,对应起来,才能正常学习呀!又浪费我好几天时间。。。
----------------------------------------------------------------------------------------------------------------------------
**onnx安装包地址
https://anaconda.org/conda-forge/onnx/files
按装方法,下载.tar文件后,进入环境,使用安装命令:
conda install --use-local 你的压缩文件的名字如: conda install --use-local onnxruntime-1.11.1-py38hf502cf8_1.tar.bz2
等待安装完毕即可。
测试:
进入环境:
1.
python
import onnx没有提示报错即可。
边栏推荐
- 删库后!除了跑路还能干什么?
- [详解C语言]一文带你玩转C语言小游戏---三子棋
- ModuleNotFoundError No module named ‘xxx‘可能的解决方案大全
- Debian 10 NTP 服务配置
- 化学试剂磷脂-聚乙二醇-羟基,DSPE-PEG-OH,DSPE-PEG-Hydroxyl,MW:5000
- UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the index ing argu
- Chapter 10 Clustering
- 【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?
- 线性代数学习笔记3-3:逆矩阵的理解
- RHCSA第二天
猜你喜欢

Phospholipid-Polyethylene Glycol-Aldehyde DSPE-PEG-Aldehyde DSPE-PEG-CHO MW: 5000

ModuleNotFoundError No module named ‘xxx‘可能的解决方案大全

UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the index ing argu

Debian 10 NTP Service Configuration

(Reposted) The relationship between hashcode and equals

Redis简单学习笔记

基于libmodbus库实现modbus TCP/RTU通信

磷脂-聚乙二醇-巯基,DSPE-PEG-Thiol,DSPE-PEG-SH,MW:5000

Problems when yolov5 calls ip camera

Deveco studio 鸿蒙app访问网络详细过程(js)
随机推荐
(forwarded) HashCode summary (2)
@Autowired详解[email protected]在static属性上的使用
多个el-select下拉框无法选中相同内容
APK的安装过程分析 PMS包管理器
redis进行持久化时,有新的写操作将如何解决——写时复制
二维数组实战项目--------《三子棋》
Week 7 Review
云服务器安装部署Nacos2.0.4版本
@ApiModel 和 @ApiModelProperty
day11--shell脚本
mysql中json类型字段用法
MySQL分组后取最大一条数据【最优解】
sh: 1: curl: not found
mysql卸载详细教程
HCIP-第十天-BGP综合实验
Redis simple study notes
np.unique()函数
SOCKS5
debian 10 nat 与路由转发
MySql创建数据表