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))
Beispiel #5
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)
weights = cfgs.init

# init
caffe.set_device(2)
caffe.set_mode_gpu()
# caffe.set_mode_cpu()

solver = caffe.SGDSolver(cfgs.solver_pt)
if weights is not None:
    solver.net.copy_from(weights)

for iter in range(500*2000):
    if debug:
        if iter % 100 == 0 and iter !=0:
            nethelper=NetHelper(solver.net)
            # nethelper.hist('data')
            # nethelper.hist('label')
            nethelper.hist('prob', filters=2,attr="blob")

            if False:
                for i in range(nethelper.net.blobs['data1'].data.shape[0]):
                    plt.subplot(221)
                    plt.imshow(nethelper.net.blobs['data1'].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()
                
            
Beispiel #7
0
import cfgs_res as cfgs
#import score
#import surgery
import os

# gen solver prototxt
# solver=CaffeSolver(debug=cfgs.debug)
# solver.sp=cfgs.sp.copy()
# solver.write(cfgs.solver_pt)

debug = True

weights = cfgs.init

# init
caffe.set_device(1)
caffe.set_mode_gpu()
# caffe.set_mode_cpu()

solver = caffe.SGDSolver(cfgs.solver_pt)
if weights is not None:
    solver.net.copy_from(weights)

for iter in range(500 * 2000):
    if debug:
        if iter % 100 == 0:
            nethelper = NetHelper(solver.net)
            # nethelper.hist('res5c_branch2c',attr="param")

    solver.step(1)