-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataset.py
More file actions
28 lines (18 loc) · 990 Bytes
/
dataset.py
File metadata and controls
28 lines (18 loc) · 990 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
from utils import *
def load_img(args, ratio = 1):
original_image = Image.open(args.image_dir)
original_image_or = original_image.convert('RGB')
original_image_or = np.array(original_image_or)
original_image_or = original_image_or / 255.0
or_height, or_width, _ = original_image_or.shape
or_image_array = original_image_or
or_target_tensor = torch.tensor(or_image_array, dtype=torch.float32, device=args.device)
original_image_re = original_image.resize((or_width//ratio, or_height//ratio))
original_image_re = original_image_re.convert('RGB')
original_image_re = np.array(original_image_re)
original_image_re = original_image_re / 255.0
height, width, _ = original_image_re.shape
re_image_array = original_image_re
target_tensor = torch.tensor(re_image_array, dtype=torch.float32, device=args.device)
data_dict = {'img': target_tensor, 'or_img': or_target_tensor, 'height':height, 'width':width}
return data_dict