当前位置:网站首页>错误:with open(txt_path,‘r‘) as f: FileNotFoundError: [Errno 2] No such file or directory:
错误:with open(txt_path,‘r‘) as f: FileNotFoundError: [Errno 2] No such file or directory:
2022-08-02 03:21:00 【woshicaiji12138】
今天在做深度学习时,出现了如下错误:
root='G:/anaconda/pythonProject2/DATA/HWDB1'
transform = transforms.Compose([transforms.Resize((64,64)),
transforms.ToTensor(),
transforms.Grayscale()
])
# 读取训练集
train_dataset =Mydataset(root+'/train.txt',num_class=10,transforms=transform)
with open(txt_path,‘r’) as f: FileNotFoundError: [Errno 2] No such file or directory: ‘G:\anaconda\pythonProject2\HWDB1/train.txt’
究其原因,在于train.txt文件格式内容都如下所示:./DATA/HWDB1/train\00000\100234.png。
而HWDB1数据集文件名为HWDB1,因而绝对路径变成了G:/anaconda/pythonProject2/HWDB1/HWDB1,自然无法找到该路径。
所以只需要将文件夹HWDB1改名为DATA,使路径名为G:\anaconda\pythonProject2\DATA\HWDB1即可。
边栏推荐
猜你喜欢
随机推荐
构造方法、方法重载、全局变量与局部变量
debian 10 nat 与路由转发
@Autowired与@Resource区别
MySQL分组后取最大一条数据【最优解】
Day34 LeetCode
DSPE-PEG-Silane,DSPE-PEG-SIL,磷脂-聚乙二醇-硅烷修饰活性基团
(转帖)hashcode和equals的关系
OD-Model [4]: SSD
Day34 LeetCode
【面经】米哈游数据开发一面二面面经
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
科研试剂DMPE-PEG-Mal 二肉豆蔻酰磷脂酰乙醇胺-聚乙二醇-马来酰亚胺
Small program (necessary common sense for development) 1
Scaffolding installation
Keil development environment installation tutorial
HCIP-第十天-BGP综合实验
云服务器安装部署Nacos2.0.4版本
MySQL常见的索引
LeetCode:1161. 最大层内元素和【BFS层序遍历】
SSM整合