-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathutils.py
More file actions
31 lines (26 loc) · 790 Bytes
/
utils.py
File metadata and controls
31 lines (26 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import torch
import scipy.io as scio
import numpy as np
def generate_masks(mask_path):
mask = scio.loadmat(mask_path + '/mask.mat')
mask = mask['mask']
mask = np.transpose(mask, [2, 0, 1])
mask_s = np.sum(mask, axis=0)
index = np.where(mask_s == 0)
mask_s[index] = 1
mask = torch.from_numpy(mask)
mask = mask.float()
mask = mask.cuda()
mask_s = torch.from_numpy(mask_s.astype(float))
mask_s = mask_s.float()
mask_s = mask_s.cuda()
return mask, mask_s
def time2file_name(time):
year = time[0:4]
month = time[5:7]
day = time[8:10]
hour = time[11:13]
minute = time[14:16]
second = time[17:19]
time_filename = year + '_' + month + '_' + day + '_' + hour + '_' + minute + '_' + second
return time_filename