-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
37 lines (28 loc) · 901 Bytes
/
utils.py
File metadata and controls
37 lines (28 loc) · 901 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
32
33
34
35
36
import os
from skimage.io import imread
from skimage import img_as_ubyte,img_as_float,exposure,color
import numpy as np
from tqdm import tqdm
import sys
indx = 250
def load_images(path,idx,count):
images = []
for fname in os.listdir(path)[idx:idx+count]:
fname = os.path.join(path, fname)
image = imread(fname) / 255.
images.append(np.atleast_3d(image))
return images
def batch_generator(path_x,batch_size,max_steps,bin_multiplier=2):
global indx
while True:
X = np.array(load_images(path_x,indx,batch_size))
Y = np.array(load_images('./data/B80/train',indx,batch_size))
if indx >= max_steps:
indx = 0
else:
indx += 1
yield (X,Y)
def load_single_pair(path_x,idx,count):
X = load_images(path_x,idx,count)
Y = load_images('./data/B80/train',idx,count)
return (X,Y)