花卉识别解析
代码部分
- cfg变量
- EasyDict可以让你像访问属性一样访问dict里的变量
#不使用EasyDict
d = {'foo':3, 'bar':{'x':1, 'y':2}}
print(d['foo']) # 如何想要访问字典的元素需要这么写
print(d['bar']['y']) # 如果想要继续访问字典中字典的元素需要使用二维数组
# print(d.foo) 这样写会出错
#使用EasyDict
from easydict import EasyDict as edict
easy = edict(d = {'foo':3, 'bar':{'x':1, 'y':2}}) # 将普通的字典传入到edict()
print(easy['foo']) # 这是传统的方法
print(easy.foo) # 这是我们使用easydict输出二者结果是一样的,但是可以更为方便的使用字典了
print(easy.bar.x) # 我们也是可以很方便的使用字典中字典的元素了
- PIL,全称 Python Imaging Library,是 Python 平台一个功能非常强大而且简单易用的图像处理库。但是,由于 PIL 仅支持到Python 2.7,加上年久失修,于是一群志愿者在 PIL 的基础上创建了兼容 Python 3 的版本,名字叫 Pillow ,我们可以通过安装 Pillow 来使用 PIL。
- num_parallel_workers的设置
train_loader = torch.utils.data.DataLoader(train_dataset,batch_size=batch_size, shuffle=True,num_workers=4)
参考文章
python中的easydict模块使用
pillow有关内容
Python PIL Image.open()用法及代码示例
pytorch中DataLoader的num_workers参数详解与设置大小建议