当前位置:网站首页>2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
2.3 [pytorch] data preprocessing torchvision datasets. ImageFolder
2022-07-01 09:08:00 【Enzo tried to smash the computer】
When we were training , We have to read in the data , Different storage methods for data , We also have different reading methods , Thus, it is convenient for us to match the training data with their labels one by one .
Mode one : It is used to read data from a folder containing all categories of data . By rewriting torch.utils.data.Dataset, Build data reading mode ( Do your own processing and match the data and labels one by one ), Finally, through the iterator torch.utils.data.DataLoader Call to , according to batch_size Read data in batches . Here are two examples :
- 【kaggle Data sets - dog breed give an example 】 Data preprocessing 、 rewrite Dataset、DataLoader Reading data
- torch.utils.data.Dataset and torch.utils.data.DataLoader Based on using
Mode two : This is what we want to introduce in this article torchcvision.datasets.ImageFolder, It is used to read data from the classified folder , Examples are as follows
Data storage structure :
from torchvision import datasets, transforms
my_trans = transforms.Compose([transforms.RandomResizedCrop(224),
transforms.ToTensor()])
train_data = datasets.ImageFolder('./animals/train', transform=my_trans)
print(train_data.class_to_idx) # View category name ( file name ) Corresponding tag value
print(train_data[0][0].size()) # The size of the first picture , It's us transforms.RandomResizedCrop Set crop size
for i in range(len(train_data)):
print(train_data[i][1]) # View the tag values mapped to all pictures in the training dataset
Output :
边栏推荐
- Football and basketball game score live broadcast platform source code /app development and construction project
- Can diffusion models be regarded as an autoencoder?
- It is designed with high bandwidth, which is almost processed into an open circuit?
- 【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DHT11 +NodeJs本地服务+ MySQL数据库
- Shell script -if else statement
- I use flask to write the website "one"
- 3. Detailed explanation of Modbus communication protocol
- 又到年中,固定资产管理该何去何从?
- Embedded Engineer Interview Question 3 Hardware
- AVL树的理解和实现
猜你喜欢
Dynamic proxy
Daily practice of C language - day 80: currency change
集团公司固定资产管理的痛点和解决方案
动态代理
I use flask to write the website "one"
Jetson Nano 安装TensorFlow GPU及问题解决
Principles of Microcomputer - Introduction
足球篮球体育比赛比分直播平台源码/app开发建设项目
Installing Oracle EE
Imitation of Baidu search results top navigation bar effect
随机推荐
C language student information management system
2.2 【pytorch】torchvision.transforms
Shell脚本-变量的定义、赋值和删除
Daily practice of C language - day 80: currency change
Shell script echo command escape character
中小企业固定资产管理办法哪种好?
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于阿里云和Arduino的化学环境系统检测,支持钉钉机器人告警
2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
Understanding and implementation of AVL tree
[ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
Graduation season, I want to tell you
Shell script - positional parameters (command line parameters)
Win7 pyinstaller reports an error DLL load failed while importing after packaging exe_ Socket: parameter error
足球篮球体育比赛比分直播平台源码/app开发建设项目
Ape anthropology topic 20 (the topic will be updated from time to time)
如何一站式高效管理固定资产?
Log4j 日志框架
Understand shallow replication and deep replication through code examples
钓鱼识别app
小鸟识别APP