This file contains hidden or 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
import torch | |
import cv2 | |
import h5py | |
import numpy as np | |
from scipy.io import loadmat | |
import torch.utils.data as data | |
import torch.nn.functional as F | |
from torchvision.transforms import Compose |
This file contains hidden or 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
def trimmed_mae_loss(prediction, target, mask, trim=0.2): | |
M = torch.sum(mask, (1, 2)) | |
res = prediction - target | |
res = res[mask.bool()].abs() | |
trimmed, _ = torch.sort(res.view(-1), descending=False)[ | |
: int(len(res) * (1.0 - trim)) | |
] |
This file contains hidden or 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
import torch | |
import glob | |
import numpy as np | |
import imageio | |
import cv2 | |
import torch.utils.data as data | |
import torch.nn.functional as F | |
from torchvision.transforms import Compose |