当前位置:网站首页>解决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没有提示报错即可。
边栏推荐
猜你喜欢
随机推荐
sh: 1: curl: not found
线性代数学习笔记3-1:矩阵与线性变换、常见矩阵(逆矩阵、伴随矩阵、正交矩阵等)
5.nodejs--cross domain, CORS, JSONP, Proxy
线性代数学习笔记1:何为线性代数
DOM destruction and reproduction experiment
AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/yolov5-5.0/models/commo
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
Good Key, Bad Key (thinking, temporary exchange, classic method)
二维数组实战项目--------《三子棋》
HCIP-第十天-BGP综合实验
Week 7 Review
MySQL分区表详解
subprocess.CalledProcessError: Command 'pip install 'thop'' returned non-zero exit status 1.
(forwarded) HashCode summary (2)
Debian 10 NTP 服务配置
MySQL分页查询的5种方法
bgp机房的动态路由和静态路由的区别
ssm各类配置模板
Monaco Editor 的基本用法
DAY-1 | 求两个正整数的最大公约数与最小公倍数之和——辗转相除法









