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 func(filename, nh): _, idx, ext = Data.splitPath(filename) if ext != ".tif": return None cfgs.cnt += 1 print(cfgs.cnt) #idx=int(idx) img = Data.imFromFile(filename) ready = prep(img, cfgs.inShape[1], cfgs.inShape[0]) # print(np.histogram(ready)) # ready*=0.00392156862745 ready -= 128 ready *= 0.0078431372549 pred_bin, pred, img = classifier(ready, nh) # pred_bin,pred,output, img=classifier(ready,nh) result = run_length_enc(pred_bin) if debug: # print('org',np.histogram(ready)) # print('data', np.histogram(img)) hist = np.histogram(img) print(pd.DataFrame(hist[0], index=hist[1][1:]).T) hist = np.histogram(pred) print(pd.DataFrame(hist[0], index=hist[1][1:]).T) mask = plt.imread(os.path.join(cfgs.train_mask_path, idx + "_mask.tif")) plt.figure(1) plt.subplot(221) plt.title('mask') plt.imshow(mask) plt.subplot(222) plt.title('prediction') plt.imshow(pred_bin) plt.subplot(223) plt.title('img') plt.imshow(img) plt.subplot(224) plt.title('heatmap ') plt.imshow(pred) plt.show() # print(idx,result) return (idx, result)
def func(filename, nh): _,idx,ext=Data.splitPath(filename) if ext!=".tif": return None cfgs.cnt+=1 print(cfgs.cnt) #idx=int(idx) img=Data.imFromFile(filename) ready=prep(img,cfgs.inShape[1],cfgs.inShape[0]) # print(np.histogram(ready)) # ready*=0.00392156862745 ready-=128 ready*=0.0078431372549 pred_bin,pred, img=classifier(ready,nh) # pred_bin,pred,output, img=classifier(ready,nh) result=run_length_enc(pred_bin) if debug: # print('org',np.histogram(ready)) # print('data', np.histogram(img)) hist=np.histogram(img) print(pd.DataFrame(hist[0],index=hist[1][1:]).T) hist=np.histogram(pred) print(pd.DataFrame(hist[0],index=hist[1][1:]).T) mask=plt.imread(os.path.join(cfgs.train_mask_path,idx+"_mask.tif")) plt.figure(1) plt.subplot(221) plt.title('mask') plt.imshow(mask) plt.subplot(222) plt.title('prediction') plt.imshow(pred_bin) plt.subplot(223) plt.title('img') plt.imshow(img) plt.subplot(224) plt.title('heatmap ') plt.imshow(pred) plt.show() # print(idx,result) return (idx,result)