Safemotion Lib
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
action_dataset_loader.ActionDatasetLoader_v22 Class Reference
Inheritance diagram for action_dataset_loader.ActionDatasetLoader_v22:

Public Member Functions

 __init__ (self, mode, data_folder, category_info, clip_len)
 
 load_data (self)
 
 preprocessing (self, sample)
 
 __len__ (self)
 
 __getitem__ (self, index)
 

Public Attributes

 mode
 
 data_folder
 
 category_info
 
 clip_len
 
 dataset
 

Detailed Description

세이프모션의 데이터셋을 기반으로 단일 경로 모델을 학습하기 위한 데이터로더
args:
    mode (str): 데이터로더의 셋팅 모드, 학습용일 경우 'train', 평가일 경우 'val'
    data_folder (str): 학습용 데이터셋이 저장된 폴더, 해당 폴더 안에는 mode 폴더가 포함되어 있어야함
    category_info (dict): 학습 데이터의 카테고리별 클래스 수
        TODO: category_info는 제거해도 동작가능할 것으로 보여짐, 코드 수정 필요
    clip_len (int): 샘플링할 프레임 수

Definition at line 92 of file action_dataset_loader.py.

Constructor & Destructor Documentation

◆ __init__()

action_dataset_loader.ActionDatasetLoader_v22.__init__ ( self,
mode,
data_folder,
category_info,
clip_len )

Definition at line 102 of file action_dataset_loader.py.

102 def __init__(self, mode, data_folder, category_info, clip_len):
103 self.mode = mode
104 self.data_folder = data_folder
105 self.category_info = category_info
106 self.clip_len = clip_len
107
108 self.load_data()
109

Member Function Documentation

◆ __getitem__()

action_dataset_loader.ActionDatasetLoader_v22.__getitem__ ( self,
index )

Definition at line 149 of file action_dataset_loader.py.

149 def __getitem__(self, index):
150 sample = self.dataset[index]
151 if isinstance(sample, list): #샘플이 리스트일 경우 한개 선택함
152 size_data = len(sample)
153
154 #인덱스 설정
155 if self.mode == 'train': #학습 모드일 경우 랜덤으로 선택
156 rand_idx = random.randint(0, size_data-1)
157 else: #평가모드일 경우 중심에서 한개 선택
158 rand_idx = size_data//2
159
160 sample = sample[rand_idx]
161
162 return self.preprocessing(sample)
163
164
165

◆ __len__()

action_dataset_loader.ActionDatasetLoader_v22.__len__ ( self)

Definition at line 146 of file action_dataset_loader.py.

146 def __len__(self):
147 return len(self.dataset)
148

◆ load_data()

action_dataset_loader.ActionDatasetLoader_v22.load_data ( self)
데이터를 로드하는 기능

Definition at line 110 of file action_dataset_loader.py.

110 def load_data(self):
111 """
112 데이터를 로드하는 기능
113 """
114 self.dataset = []
115 for category, num in self.category_info.items(): #카테고리, 클래스 수
116 folder = os.path.join(self.data_folder, self.mode, category) #카테고리-클래스의 데이터 폴더
117 name_list, path_list = search_file(folder, '.pkl') #해당 폴더의 모든 pkl파일 검색
118
119 #데이터 로드
120 data_num = len(path_list)
121 for i, (name, path) in enumerate(zip(name_list, path_list)):
122 print(f'{self.mode} : {category} [{i+1}/{data_num}] -> {name}', end='\r')
123 pkl = load_pkl_data(path)
124 self.dataset.append(pkl)
125

◆ preprocessing()

action_dataset_loader.ActionDatasetLoader_v22.preprocessing ( self,
sample )
모델의 입력을 위한 데이터 전처리 기능
스켈레톤의 히트맵을 생성하는게 메인 기능임, 데이터 증강(data augmentation) 포함됨
TODO: 데이터 증강은 학습 모드일 경우만 진행되도록 코드 변경 필요
args:
    sample (dict): 모델의 입력을 생성하기 위한 데이터
return (dict): 모델의 입력이 포함된 데이터

Definition at line 126 of file action_dataset_loader.py.

126 def preprocessing(self, sample):
127 """
128 모델의 입력을 위한 데이터 전처리 기능
129 스켈레톤의 히트맵을 생성하는게 메인 기능임, 데이터 증강(data augmentation) 포함됨
130 TODO: 데이터 증강은 학습 모드일 경우만 진행되도록 코드 변경 필요
131 args:
132 sample (dict): 모델의 입력을 생성하기 위한 데이터
133 return (dict): 모델의 입력이 포함된 데이터
134 """
135 sample = pose_sampling(sample, clip_len=self.clip_len) #샘플링
136 sample = pose_shift(sample, shift_ratio=0.05) #스켈레톤 이동, 데이터 증강
137 sample = pose_compact(sample) #스켈레톤 범위 셋팅
138 sample = pose_resize(sample, scale=(64, 64)) #리사이즈
139 sample = pose_random_crop(sample, area_range=(0.56, 1.0), aspect_ratio_range=(3 / 4, 4 / 3)) #랜덤 크롭, 데이터 증강
140 sample = pose_resize(sample, scale=(56, 56)) #리사이즈, 크롭을 진행했기 때문에 다시 리사이즈 해줌
141 sample = pose_flip(sample, flip_ratio=0.5) #좌우 반전, 데이터 증강
142 sample = make_pose_heatmap(sample) #히트맵 생성
143
144 return sample
145

Member Data Documentation

◆ category_info

action_dataset_loader.ActionDatasetLoader_v22.category_info

Definition at line 105 of file action_dataset_loader.py.

◆ clip_len

action_dataset_loader.ActionDatasetLoader_v22.clip_len

Definition at line 106 of file action_dataset_loader.py.

◆ data_folder

action_dataset_loader.ActionDatasetLoader_v22.data_folder

Definition at line 104 of file action_dataset_loader.py.

◆ dataset

action_dataset_loader.ActionDatasetLoader_v22.dataset

Definition at line 114 of file action_dataset_loader.py.

◆ mode

action_dataset_loader.ActionDatasetLoader_v22.mode

Definition at line 103 of file action_dataset_loader.py.


The documentation for this class was generated from the following file: