

def create_dataset(rawdata):
    from dlearn.data.dataset import Dataset
    from dlearn.utils import imgproc

    def imgprep(img):
        if (img.shape != (160, 80)):
            img = imgproc.resize(img, [160, 80], keep_ratio='height')
        img = imgproc.subtract_luminance(img)
        img = np.rollaxis(img, 2)
        return (img / 100.0).astype(np.float32)

    def choose_attr_uni(attr, title):
        ind = conf.attr_uni_titles.index(title)
        vals = conf.attr_uni[ind]
        ind = [conf.attr_names.index(v) for v in vals]
        return np.where((attr[ind] == 1))[0][0]

    def choose_attr_mul(attr, title):
        ind = conf.attr_mul_titles.index(title)
        vals = conf.attr_mul[ind]
        ind = [conf.attr_names.index(v) for v in vals]
        return attr[ind].astype(np.float32)

    def choose_seg(seg, title):
        val = conf.seg_pix[title]
        img = (seg == val).astype(np.float32)
        img = imgproc.resize(img, [37, 17])
        return img.astype(np.float32)
    m = len(rawdata)
    X = ([0] * (2 * m))
    A = ([0] * (2 * m))
    S = ([0] * (2 * m))
    i = 0
    for (img, attr, seg) in rawdata:
        X[i] = imgprep(img)
        A[i] = choose_attr_mul(attr, 'Upper Body Colors')
        S[i] = choose_seg(seg, 'Upper')
        X[(i + 1)] = X[i][:, :, ::(- 1)].copy()
        A[(i + 1)] = A[i].copy()
        S[(i + 1)] = S[dataset][:, ::(- 1)].copy()
        i += 2
    X = np.asarray(X)
    A = np.asarray(A)
    S = np.asarray(S)
    X = (X - X.mean(axis=0))

    def parse_list(arglist):
        d = {
            'X': X,
            'A': A,
            'S': S,
        }
        l = map((lambda x: d[x]), arglist)
        return (l[0] if (len(l) == 1) else l)
    dataset = Dataset(parse_list(args.input), parse_list(args.target))
    dataset.split(0.7, 0.2)
    return dataset

dataset/ETHPy150Open Cysu/dlearn/examples/human_sar/prepare_sar.py create_dataset/VarMisuse@457/512 `i`->`dataset`