def batch_rgbtb(root): df = get_trip(root) in_dirs = [ osp.join(root, 'rgbc', 'origin'), osp.join(root, 'rgbc', 'derived') ] dfi = df.applymap(lambda x: osp.join(in_dirs[0], x + '.jpg')) dfi[["fo", "m"]] = df[["f", "ab" ]].applymap(lambda x: osp.join(in_dirs[1], x + '.jpg')) dfi = dfi.to_numpy() out_dirs = [ osp.join(root, 'rgbc', 'thumbnail', 'origin'), osp.join(root, 'rgbc', 'thumbnail', 'derived') ] for d in out_dirs: mkdir(d) dfo = df.applymap(lambda x: osp.join(out_dirs[0], x + '.jpg')) dfo[["fo", "m"]] = df[["f", "ab" ]].applymap(lambda x: osp.join(out_dirs[1], x + '.jpg')) dfo = dfo.to_numpy() with Pool(16, initialize_tbnail, (16, )) as p: ares = p.starmap_async(tbnail_rgb, zip(dfi, dfo)) ares.wait()
def batch_crop_rgb(root): df = get_trip(root) in_dirs = [ osp.join(root, 'rgb', 'origin'), osp.join(root, 'rgb', 'derived') ] dfi = df.applymap(lambda x: osp.join(in_dirs[0], x + '.jpg')) dfi[["fo", "m"]] = df[["f", "ab" ]].applymap(lambda x: osp.join(in_dirs[1], x + '.jpg')) dfi = dfi.to_numpy() out_dirs = [ osp.join(root, 'rgbc', 'origin'), osp.join(root, 'rgbc', 'derived') ] for d in out_dirs: mkdir(d) dfo = df.applymap(lambda x: osp.join(out_dirs[0], x + '.jpg')) dfo[["fo", "m"]] = df[["f", "ab" ]].applymap(lambda x: osp.join(out_dirs[1], x + '.jpg')) dfo = dfo.to_numpy() dfbd = (pd.read_csv(osp.join(root, root + '.csv'))[["w1", "h1", "w2", "h2"]]).to_numpy() # print(dfi[50]) # crop_rgb(dfi[50],dfo[50],dfbd[50]) # return with Pool(16) as p: ares = p.starmap_async(crop_rgb, zip(dfi, dfo, dfbd)) ares.wait()
def cvts(root, fm1='dng', fm2='jpg', num_worker=3): dir1, dir2 = osp.join(root, fm1), osp.join(root, fm2) ls1 = os.listdir(dir1) mkdir(dir2) outputs = bj(dir2, be(ls1, fm2)) inputs = bj(dir1, ls1) with Pool(num_worker) as p: p.starmap_async(convert, zip(inputs, outputs))
def save(self, filepath: str) -> None: df = DataFrame(columns=("num", "rank", "num_batches", "cost")) for epoch in self.epochs: row = { "num": epoch.num, "rank": epoch.rank, "num_batches": epoch.num_batches, "cost": epoch.cost, } df = df.append(row, ignore_index=True) mkdir(filepath) df.to_csv(filepath)
def batch5rgb(root: str, processes=16): df = get_trip(root) dfi = df.applymap(lambda x: osp.join(root, 'raw', x + '.dng')).to_numpy() out_dirs = [ osp.join(root, 'rgb', 'origin'), osp.join(root, 'rgb', 'derived') ] for d in out_dirs: mkdir(d) dfo = df.applymap(lambda x: osp.join(out_dirs[0], x + '.jpg')) dfo[["fo", "m"]] = df[["f", "ab" ]].applymap(lambda x: osp.join(out_dirs[1], x + '.jpg')) dfo = dfo.to_numpy() # get5rgb(dfi[0],dfo[0]) # return with Pool(16) as p: ares = p.starmap_async(get5rgb, zip(dfi, dfo)) ares.wait()
def batch5rawc(root: str, processes=16): df = get_trip(root) dfi = df.applymap(lambda x: osp.join(root, 'raw', x + '.dng')).to_numpy() out_dirs = [ osp.join(root, 'rawc', 'origin'), osp.join(root, 'rawc', 'derived') ] for d in out_dirs: mkdir(d) dfo = df.applymap(lambda x: osp.join(out_dirs[0], x + '.png')) dfo[["fo", "m"]] = df[["f", "ab" ]].applymap(lambda x: osp.join(out_dirs[1], x + '.png')) dfo = dfo.to_numpy() dfbd = (pd.read_csv(osp.join(root, root + '.csv'))[["w1", "h1", "w2", "h2"]]).to_numpy() # get5rawc(dfi[0],dfo[0],dfbd[0]) # return with Pool(16) as p: ares = p.starmap_async(get5rawc, zip(dfi, dfo, dfbd)) ares.wait()