data block API를 사용해서 데이터를 DataLoaders에 모아보자.

 

(참고)

blog.usejournal.com/finding-data-block-nirvana-a-journey-through-the-fastai-data-block-api-c38210537fe4

 

1.pets = DataBlock(blocks=(ImageBlock, CategoryBlock),

get_items=get_image_files,

splitter=RandomSplitter(),

get_y=using_attr(RegexLabeller(r'(.+)_\d+.jpg$'), 'name'),

item_tfms=Resize(460),

batch_tfms=aug_transforms(size=224))

 

blocks = 이미지블락, 카테고리블락

get_image_fils = 날것의 아이템을 얻는 방법

regular expression = 라벨된 아이템을 얻는 방법

random splitter = 아이템을 스플릿하는 방법

item_tfms, batch_tfms

 

=> pet 객체 자체는 비어있고, 데이터를 모으는 데 도움이 되는 function만 가지고 있다.

 

2. path = untar_data(URLs.PETS)

 

3. dls = pets.dataloaders(path/"images")

 

이렇게 data block API를 사용해서 데이터 로드 함수를 사용할 수 있다.

dls는 이전과 같이 DataLoaders다.

 

4.dls.show_batch(max_n = 9)

+ Recent posts