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))
Esempio n. 3
0
    def train_model(self):
        for iter in range(500 * 2000):
            if debug:
                if iter % 100 == 0 and iter != 0:
                    nethelper = NetHelper(self.solver.net)
                    # nethelper.hist('label')
                    # nethelper.hist('prob', filters=2,attr="blob")
                    # nethelper.hist('data', filters=2,attr="blob")

                    if False:
                        for i in range(
                                nethelper.net.blobs['data'].data.shape[0]):
                            plt.subplot(221)
                            plt.imshow(nethelper.net.blobs['data'].data[i, 0])
                            plt.subplot(222)
                            plt.imshow(nethelper.net.blobs['prob'].data[i, 0])
                            plt.subplot(223)
                            plt.imshow(nethelper.net.blobs['label'].data[i, 0])
                            plt.show()

            self.solver.step(1)