【pytorch | torchvision | datasets】ImageFolder()类

Class ImageFolder##

class torchvision.datasets.ImageFolder(root: ~typing.Unionstr, \~pathlib.Path, transform: ~typing.Optional~typing.Callable = None, target_transform: ~typing.Optional~typing.Callable = None, loader: ~typing.Callable\[str, ~typing.Any] = , is_valid_file: ~typing.Optional~typing.Callable\[\[str, bool]] = None, allow_empty: bool = False)

就该类输出的格式

A generic data loader where the images are arranged in this way by default:

一个通用的默认排列方式的图像数据加载器:

root/dog/xxx.png

root/dog/xxy.png

root/dog/.../xxz.png


root/cat/123.png

root/cat/nsdf3.png

root/cat/.../asd932_.png

parameters;

This class inherits from DatasetFolder so the same methods can be overridden to customize the dataset.

  • Parameters:
    • root (str or pathlib.Path) -- Root directory path.

    • transform (callable, optional) -- A function/transform that takes in a PIL image or torch.Tensor, depends on the given loader, and returns a transformed version. E.g, transforms.RandomCrop

    • target_transform (callable, optional) -- A function/transform that takes in the target and transforms it.

    • loader (callable, optional) -- A function to load an image given its path.

    • is_valid_file (callable, optional) -- A function that takes path of an Image file and check if the file is a valid file (used to check of corrupt files)

    • allow_empty -- If True, empty folders are considered to be valid classes. An error is raised on empty folders if False (default).

参数

  • root (数据集根目录路径)
  • transform (可选参数;回调函数。就是torchvision中的transform模块中的类对象)。ImageFolder类对象并不会立即执行,而是在你需要该数据时 才会对root路径下的数据进行执行该函数。
相关推荐
必须得开心呀12 分钟前
python编写带界面的软件,需要安装哪些插件
开发语言·python
Wx-bishekaifayuan19 分钟前
express皖美特色农产品网售系统53118-计算机课程设计、毕业设计
人工智能·spring boot·后端·python·课程设计·express·旅游
loulanyue_24 分钟前
从个人提效到团队可验证交付:中宏保险AI Coding流水线重塑与Qoder实战——读中宏保险AI架构总监王志宇2026云栖专场演讲
人工智能·架构
砚凝霜34 分钟前
【软考信息安全】第十章 入侵检测概述与原理分类
人工智能·安全·数据挖掘
青少儿编程课堂1 小时前
迪杰斯特拉(Dijkstra)算法:单源最短路与赛场路线规划
c++·python·算法·bfs·信息学竞赛
鬓戈1 小时前
Logits 到底是什么
人工智能
计算机编程指导师1 小时前
【计算机毕设推荐】基于Hadoop+Spark的公共交通运营数据分析与可视化系统源码 毕业设计 选题推荐 毕设选题 数据分析 机器学习
大数据·hadoop·python·计算机·数据分析·spark·交通
Wx-bishekaifayuan1 小时前
springboot汉中旅游服务平台41442-计算机课程设计、毕业设计
spring boot·后端·python·django·课程设计·express·旅游
golang学习记1 小时前
Zed 新特性:AI 还在跑,电脑可以不睡了
人工智能·vscode·电脑·zed
愤怒的代码1 小时前
浅析模型量化的数学原理
人工智能