のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

fastai split_by_idxs

各関数を分解しながら、代入していった。

#その3
#data = ImageDataBunch.from_csv(path, ds_tfms=tfms, size=128)
folder      = None
label_delim = None
csv_labels  = 'labels.csv'
valid_pct   = 0.2
fn_col      = 0
label_col   = 1
suffix      = '' 
delimiter   = None
header      ='infer'

path2 = Path(path)
df = pd.read_csv(path2/csv_labels, header=header, delimiter=delimiter)

src1 = ImageList.from_df(df, path=path2, folder=folder, suffix=suffix, cols=fn_col)
DAI1_LEN=2965
mid = DAI1_LEN * 10
end = len(src1)
valid_idx = list(range(0,   mid))
train_idx = list(range(mid, end))

src2 = src1.split_by_idxs(train_idx, valid_idx)
src3 = src2.label_from_df(label_delim=label_delim, cols=label_col)
data3 = ImageDataBunch.create_from_ll(src3, size=128)
DATA = data3