当前位置:网站首页>Deep learning - make your own dataset

Deep learning - make your own dataset

2022-07-07 17:41:00 AI cannon fodder

1. background

For folder set subfolders , There are many images of the same category in the subfolder , Subfolders represent the categories of images inside . The file with this structure is called image cascading, which is imageFolder. As shown below :

Under this folder are 10 Subfolders of categories , as follows :

 

There are many images under each subfolder , as follows :

 2. Start making dataset

"""
     There are multiple folders under one folder , Each subfolder is the class alias of the pictures in the subfolder , This kind of appellation image stacking form imageFolder.
"""
import os
from torch.utils.data import Dataset, DataLoader, random_split
import pandas as pd
import numpy as np


dataset_dir = "F:/reshape_images"

#  Get the number of subfolders , That is, the number of categories 
classes = os.listdir(dataset_dir)
print(classes)

#  Define an array to store filename, filepath, label, So the definition of 
原网站

版权声明
本文为[AI cannon fodder]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071529540480.html