jupyter notebook中使用ImageFolder来加载文件夹时把.ipynb_checkpoints文件夹忽略
2018-03-04 17:04
1166 查看
from torchvision.datasets import ImageFolder dataset = ImageFolder('data/dogcat_2/') dataset.class_to_idx输出:{'.ipynb_checkpoints': 0, 'cat': 1, 'dog': 2}将~/python3.6/site-packages/torchvision/datasets/folder.py的源代码改一下即:
将以下函数进行更改:def find_classes(dir):
classes = [d for d in os.listdir(dir) if os.path.isdir(os.path.join(dir, d)) ]
classes.sort()
class_to_idx = {classes[i]: i for i in range(len(classes))}
return classes, class_to_idx更改后为:def find_classes(dir):
classes = [d for d in os.listdir(dir) if os.path.isdir(os.path.join(dir, d)) and not d.startswith('.')]
classes.sort()
class_to_idx = {classes[i]: i for i in range(len(classes))}
return classes, class_to_idx
from torchvision.datasets import ImageFolder dataset = ImageFolder('data/dogcat_2/') dataset.class_to_idx输出:{'cat': 0, 'dog': 1}
相关文章推荐
- Jupyter使用 | Jupyter Notebook打开默认文件夹以外的文件
- Jupyter notebook 使用 [持续更新]
- Mac 中卸载anaconda使用pip安装jupyter notebook
- 机器学习(三) Jupyter Notebook, numpy和matplotlib的详细使用 (上)
- Jupyter notebook使用
- Jupyter Notebook 使用总结 Pycharm
- Jupyter Notebook使用笔记
- jupyter notebook使用技巧
- Mac下Jupyter(即IPython-notebook)的搭建及使用(更建议安装Anaconda环境直接自带jupyter notebook)
- 使用jupyter notebook 学习tensorflow
- pycharm中使用jupyter notebook——利用pip安装jupyter
- conda创建的虚拟环境中使用jupyter notebook如何关闭
- 本地使用服务器端运行的Jupyter Notebook
- Jupyter Notebook各种使用方法记录
- Jupyter NoteBook 的快捷键使用指南
- jupyter notebook的安装与使用
- Jupyter notebook中设定py2py3同时使用
- Jupyter Notebook 相关内容和使用的教程
- Jupyter notebook使用
- Jupyter Notebook使用笔记(二)