当前位置:网站首页>解决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
没有提示报错即可。
边栏推荐
- Dynamic proxy tool class
- PCL—点云数据分割
- Keil development environment installation tutorial
- OD-Model [4]: SSD
- 线性代数学习笔记3-3:逆矩阵的理解
- 磷脂-聚乙二醇-巯基,DSPE-PEG-Thiol,DSPE-PEG-SH,MW:5000
- np.unique() function
- MySQL分组后取最大一条数据【最优解】
- MySql创建数据表
- IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
猜你喜欢
[详解C语言]一文带你玩转C语言小游戏---三子棋
知识工程作业2:知识工程相关领域介绍
MySql创建数据表
day11--shell脚本
oracle inner join and outer join
LeetCode:1374. 生成每种字符都是奇数个的字符串【签到题】
[Basic Tutorial of Remote Control Development 1] Crazy Shell Open Source Formation Drone-GPIO (Remote Control Indicator Light Control)
Week 7 Review
亚马逊卖家怎么提升转化率
AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
随机推荐
Daily practice------There are n integers, so that the previous numbers are moved back m positions in order, and the last m numbers become the first m numbers
(Repost) HashCode Summary (1)
MySQL分组后取最大一条数据【最优解】
About cross-domain issues
@Accessors 注解详解
JJWT工具类
代码随想录笔记_哈希_383赎金信
Debian 10 NTP 服务配置
「PHP基础知识」PHP中对象的使用
parser = argparse.ArgumentParser()解析
@Autowired与@Resource区别
Day34 LeetCode
知识工程作业2:知识工程相关领域介绍
Scaffolding installation
MySQL分页查询的5种方法
Mysql8创建用户以及赋权操作
Freeswitch操作基本配置
2022.7.30 js notes Operators and flow controllers, loops
Redis笔记进阶篇:万字长文-整理Redis,各种知识点,建议收藏
【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?