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

Public Member Functions

 __init__ (self, mode, train_data_folder, test_data_folder, clip_len)
 
 load_data (self)
 
 preprocessing (self, sample)
 
 __len__ (self)
 
 __getitem__ (self, index)
 

Public Attributes

 mode
 
 train_data_folder
 
 test_data_folder
 
 clip_len
 
 dataset
 

Detailed Description

세이프모션의 학습용 데이터를 기반으로하는 데이터로더
학습용 데이터는 '.pkl'파일로 구성됨
TODO: 사용하지 않을 가능성이 커보임, 삭제 요망
args:
    mode (str): 데이터로더의 셋팅 모드, 학습용일 경우 'train', 평가일 경우 'val'
    train_data_folder (str): 학습용 데이터가 저장된 폴더 또는 파일
    test_data_folder (str): 평가용 데이터가 저장된 폴더 또는 파일
    clip_len (int): 샘플링할 프레임 수

Definition at line 18 of file action_dataset_loader.py.

Constructor & Destructor Documentation

◆ __init__()

action_dataset_loader.ActionDatasetLoader.__init__ ( self,
mode,
train_data_folder,
test_data_folder,
clip_len )

Definition at line 29 of file action_dataset_loader.py.

29 def __init__(self, mode, train_data_folder, test_data_folder, clip_len):
30 self.mode = mode
31 self.train_data_folder = train_data_folder
32 self.test_data_folder = test_data_folder
33 self.clip_len = clip_len
34
35 self.load_data()
36

Member Function Documentation

◆ __getitem__()

action_dataset_loader.ActionDatasetLoader.__getitem__ ( self,
index )

Definition at line 81 of file action_dataset_loader.py.

81 def __getitem__(self, index):
82 sample = self.dataset[index]
83 if isinstance(sample, list): #샘플이 리스트일 경우 랜덤으로 한개 선택함
84 size_data = len(sample) #리스트 크기
85
86 #랜덤으로 선택
87 rand_idx = random.randint(0, size_data-1)
88 sample = sample[rand_idx]
89
90 return self.preprocessing(sample)
91

◆ __len__()

action_dataset_loader.ActionDatasetLoader.__len__ ( self)

Definition at line 78 of file action_dataset_loader.py.

78 def __len__(self):
79 return len(self.dataset)
80

◆ load_data()

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

Definition at line 37 of file action_dataset_loader.py.

37 def load_data(self):
38 """
39 데이터를 로드하는 기능
40 """
41
42 #모드에 따른 데이터 경로 설정
43 data_folder = self.train_data_folder if self.mode == 'train' else self.test_data_folder
44 if os.path.isdir(data_folder): #데이터 경로가 폴더일 경우
45 #폴더 내부의 .pkl 파일을 모두 검색
46 name_list, path_list = search_file(data_folder, '.pkl')
47
48 #데이터 로드
49 self.dataset = []
50 for name, path in zip(name_list, path_list):
51 pkl = load_pkl_data(path)
52 self.dataset.append(pkl)
53 else:
54 #데이터 로드
55 self.dataset = load_pkl_data(data_folder)
56

◆ preprocessing()

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

Definition at line 57 of file action_dataset_loader.py.

57 def preprocessing(self, sample):
58 """
59 모델의 입력을 위한 데이터 전처리 기능
60 스켈레톤의 히트맵을 생성하는게 메인 기능임, 데이터 증강(data augmentation) 포함됨
61 TODO: 데이터 증강은 학습 모드일 경우만 진행되도록 코드 변경 필요
62 args:
63 sample (dict): 모델의 입력을 생성하기 위한 데이터
64 return (dict): 모델의 입력이 포함된 데이터
65 """
66
67 sample = pose_sampling(sample, clip_len=self.clip_len) #샘플링
68 sample = pose_shift(sample, shift_ratio=0.05) #스켈레톤 이동, 데이터 증강
69 sample = pose_compact(sample) #스켈레톤 범위 셋팅
70 sample = pose_resize(sample, scale=(64, 64)) #리사이즈
71 sample = pose_random_crop(sample, area_range=(0.56, 1.0), aspect_ratio_range=(3 / 4, 4 / 3)) #랜덤 크롭, 데이터 증강
72 sample = pose_resize(sample, scale=(56, 56)) #리사이즈, 크롭을 진행했기 때문에 다시 리사이즈 해줌
73 sample = pose_flip(sample, flip_ratio=0.5) #좌우반전, 데이터 증강
74 sample = make_pose_heatmap(sample) #히트맵 생성
75
76 return sample
77

Member Data Documentation

◆ clip_len

action_dataset_loader.ActionDatasetLoader.clip_len

Definition at line 33 of file action_dataset_loader.py.

◆ dataset

action_dataset_loader.ActionDatasetLoader.dataset

Definition at line 49 of file action_dataset_loader.py.

◆ mode

action_dataset_loader.ActionDatasetLoader.mode

Definition at line 30 of file action_dataset_loader.py.

◆ test_data_folder

action_dataset_loader.ActionDatasetLoader.test_data_folder

Definition at line 32 of file action_dataset_loader.py.

◆ train_data_folder

action_dataset_loader.ActionDatasetLoader.train_data_folder

Definition at line 31 of file action_dataset_loader.py.


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