forked from remotebiosensing/rppg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DaeyeolKim
committed
Sep 2, 2021
1 parent
bb3c728
commit c5aacf3
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import numpy as np | ||
import torch | ||
import torchvision.transforms as transforms | ||
from torch.utils.data import Dataset | ||
|
||
|
||
class RTNetDataset(Dataset): | ||
def __init__(self, face_data, mask_data, target): | ||
self.transform = transforms.Compose([transforms.ToTensor()]) | ||
self.face = face_data | ||
self.mask = mask_data | ||
self.label = target.reshape(-1, 1) | ||
|
||
def __getitem__(self, index): | ||
if torch.is_tensor(index): | ||
index = index.tolist() | ||
|
||
appearance_data = torch.tensor(np.transpose(self.face[index], (2, 0, 1)), dtype=torch.float32) | ||
motion_data = torch.tensor(np.transpose(self.mask[index], (2, 0, 1)), dtype=torch.float32) | ||
target = torch.tensor(self.label[index], dtype=torch.float32) | ||
|
||
inputs = torch.stack([appearance_data,motion_data],dim=0) | ||
|
||
if torch.cuda.is_available(): | ||
inputs = inputs.to('cuda') | ||
target = target.to('cuda') | ||
|
||
return inputs, target | ||
|
||
def __len__(self): | ||
return len(self.label) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters