def testSingleImg():
    NetHelper.gpu()
    #submission()
    nh = NetHelper(deploy=cfgs.deploy_pt, model=cfgs.best_model_dir)
    img = Data.imFromFile(os.path.join(cfgs.train_mask_path, "1_1_mask.tif"))
    res = nh.bin_pred_map(img)
    print(np.histogram(res))
def testSingleImg():
    NetHelper.gpu()
    #submission()
    nh=NetHelper(deploy=cfgs.deploy_pt,model=cfgs.best_model_dir)
    img=Data.imFromFile(os.path.join(cfgs.train_mask_path,"1_1_mask.tif"))
    res=nh.bin_pred_map(img)
    print(np.histogram(res))
def submission():

    NetHelper.gpu(2)
    #submission()
    nh = NetHelper(deploy=cfgs.deploy_pt, model=cfgs.best_model_dir)
    if debug:
        l = Data.folder_opt(cfgs.train_data_path, func, nh)
    else:
        l = Data.folder_opt(cfgs.test_data_path, func, nh)
    l = np.array(l, dtype=[('x', int), ('y', object)])
    l.sort(order='x')

    first_row = 'img,pixels'
    file_name = 'submission.csv'

    with open(file_name, 'w+') as f:
        f.write(first_row)
        for i in l:
            s = str(i[0]) + ',' + i[1]
            f.write(('\n' + s))
def submission():

    NetHelper.gpu(2)
    #submission()
    nh=NetHelper(deploy=cfgs.deploy_pt,model=cfgs.best_model_dir)
    if debug:
        l=Data.folder_opt(cfgs.train_data_path,func,nh)
    else:
        l=Data.folder_opt(cfgs.test_data_path,func,nh)
    l=np.array(l,dtype=[('x',int),('y',object)])
    l.sort(order='x')

    first_row = 'img,pixels'
    file_name = 'submission.csv'

    with open(file_name, 'w+') as f:
        f.write(first_row)
        for i in l:
            s = str(i[0]) + ',' + i[1]
            f.write(('\n'+s))