示例#1
0
def main(cfg):

    # TODO: implement device selection
    # if config.device == "auto":
    #     device =
    # elif config.device == "cpu":
    #     net = net.cpu()
    # elif config.device == "gpu":
    #     net = net.cuda()
    # else:q
    #     raise ValueError

    if cfg.mode.startswith("train"):
        run_train(cfg)

    elif cfg.mode.startswith("test"):
        # take the best model on validation set
        cfg.pretrained_model = r'global_min_acer_model.pth'
        run_test(cfg, dir='global_test_36_TTA')

    elif cfg.mode == 'realtime':
        cfg.pretrained_model = r'global_min_acer_model.pth'
        run_realtime(cfg)

    return
示例#2
0
文件: datasets.py 项目: 162/MLNS
def test_raw_set(dataset, mode):
    for item in dataset:
        run_test(item['path'] + item['name'],
                 item['width'],
                 item['height'],
                 item['scale'],
                 item['radius'],
                 item['cellsize'],
                 save_as=item['path'] + item['saveas'],
                 status=True,
                 mode=mode)
示例#3
0
def handle_argument(argument):
    if argument == "-all":
        test_all()
    elif argument == "-example":
        if len(argv) != 3:
            print("-example takes as input the name of the example to run. Please run with 'python main.py -example NAME_OF_EXAMPLE.graph'")
            return
        run_test(argv[2])
    elif argument == "-file":
        if len(argv) != 3:
            print("-file takes as input the name of the example to run. Please run with 'python main.py -file PATH/TO/FILE.graph'")
            return
        run_file(argv[2])
    else:
        print("Unrecognized command.")
示例#4
0
def launch_closerlook(params):
    import sys
    sys.path.insert(0, '/private/home/sbaio/aa/dataset_design_few_shot/cl_fsl')
    from train import run
    from save_features import run_save
    from test import run_test
    print('Launching Closer Look training with params', params)

    # train
    run(params)

    # save features
    run_save(params)

    # test
    run_test(params)
示例#5
0
文件: dv.py 项目: wehu/pydv
 def body():
     res = run_test(*opts.test,
                    action=opts.action,
                    where=opts.where)
     if type(res) == GeneratorType:
         yield from res
     return res
示例#6
0
def main():
    args = command.command()
    if args.test:
        test.run_test()
        return 0

    if args.folder is None:
        print("folder is a required argument if not using test option ")
        return 0

    if os.path.exists(args.folder):
        if args.duplicates:
            command.remove_duplicates_decision(args.folder)
        if args.order:
            command.file_order_decision(args.folder)
    else:
        print("The folder does not exist")
示例#7
0
 def test(self):
     # Run test
     self.test_result, self.test_result_pp = run_test(
         model=self.model,
         args=self.args,
         device=self.device,
         result_dir=os.path.join(self.base_dir, "test"),
     )
示例#8
0
def old_way():
    test.run_test()

    G = nx.Graph()

    keys = settings.test_set.keys()
    for i in range(0, len(keys)):
        for j in range(i + 1, len(keys)):
            G.add_edge(keys[i], keys[j], weight=settings.links[i][j])

    # G.add_edge('A', 'B', weight=0.1)
    # G.add_edge('B', 'D', weight=2)
    # G.add_edge('A', 'C', weight=3)
    # G.add_edge('C', 'D', weight=4)

    nx.draw(G, with_labels=True)
    plt.show()
示例#9
0
def   angle_y_test(error_list,path):
   	error_list.append(Picture(run_test(path + "/vlc/angled/y_axis/-27.jpg",False,'test_rig'),
                        path + "/vlc/angled/y_axis/-27.jpg",
                        "-27 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/y_axis/-18.jpg",False,'test_rig'),
                        path + "/vlc/angled/y_axis/-18.jpg",
                        "-18 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/y_axis/-9.jpg",False,'test_rig'),
                        path + "/vlc/angled/y_axis/-9.jpg",
                        "-9 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/y_axis/0.jpg",False,'test_rig'),
                        path + "/vlc/angled/y_axis/0.jpg",
                        "0 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/y_axis/9.jpg",False,'test_rig'),
                        path + "/vlc/angled/y_axis/9.jpg",
                        "9 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/y_axis/18.jpg",False,'test_rig'),
                        path + "/vlc/angled/y_axis/18.jpg",
                        "18 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/y_axis/27.jpg",False,'test_rig'),
                        path + "/vlc/angled/y_axis/27.jpg",
                        "27 deg y axis Rotation, 5 Light Source",
                        0))
   	return error_list
示例#10
0
def check(challenge_name, submission):
    display(Markdown(f'### Testing: {challenge_name}'))
    success, passed, failed = run_test(challenge_name, submission)
    for args, expected, actual in failed:
        print('Input: {}'.format(copy_args))
        print('Expected: {!r}' % expected)
        print('Got back: {!r}' % actual)

    _display('SUCCESS' if success else 'FAIL', success)
示例#11
0
文件: datasets.py 项目: 162/MLNS
def test_formed_set(name,
                    number,
                    size,
                    scale,
                    radius,
                    cellsize,
                    mode,
                    subfolder=''):
    if subfolder:
        try:
            os.stat('results/' + name + subfolder)
        except:
            os.mkdir('results/' + name + subfolder)
    for i in range(1, number + 1):
        run_test('tests/' + name + '/test' + str(i) + '.bmp',
                 size[0],
                 size[1],
                 scale,
                 radius,
                 cellsize,
                 save_as='results/' + name + subfolder + '/test' + str(i) +
                 mode + '.png',
                 status=True,
                 mode=mode)
示例#12
0
def   angle_z_test(error_list,path):
   	error_list.append(Picture(run_test(path + "/vlc/angled/z_axis/0.jpg",False,'test_rig'),
                        path + "/vlc/angled/z_axis/0.jpg",
                        "0 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/z_axis/45.jpg",False,'test_rig'),
                        path + "/vlc/angled/z_axis/45.jpg",
                        "45 deg y axis Rotation, 5 Light Source",
                        0))
        error_list.append(Picture(run_test(path + "/vlc/angled/z_axis/90.jpg",False,'test_rig'),
                        path + "/vlc/angled/z_axis/90.jpg",
                        "90 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/z_axis/135.jpg",False,'test_rig'),
                        path + "/vlc/angled/z_axis/135.jpg",
                        "135 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/z_axis/180.jpg",False,'test_rig'),
                        path + "/vlc/angled/z_axis/180.jpg",
                        "180 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/z_axis/225.jpg",False,'test_rig'),
                        path + "/vlc/angled/z_axis/225.jpg",
                        "225 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/z_axis/270.jpg",False,'test_rig'),
                        path + "/vlc/angled/z_axis/270.jpg",
                        "270 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/z_axis/315.jpg",False,'test_rig'),
                        path + "/vlc/angled/z_axis/315.jpg",
                        "315 deg y axis Rotation, 5 Light Source",
                        0))
   	error_list.append(Picture(run_test(path + "/vlc/angled/z_axis/0.jpg",False,'test_rig'),
                        path + "/vlc/angled/z_axis/0.jpg",
                        "0 deg y axis Rotation, 5 Light Source",
                        0))
	return error_list
示例#13
0
def run_all():
    start = time.time()
    for mode in modes:
        for order in orders:
            for sort in sorting.__all__:
                for n in sizes:
                    factory = Factory(n, order=order, mode=mode)
                    data = test.run_test(sort, factory)
                    try:
                        test.write_result_line(data)
                    except Exception:
                        print('data: \n', data)

                print('%s concluido' % str(sort).split(' ')[1])
            print('%s concluido' % order)
        print('%s concluido' % mode)
    end = time.time() - start
    print('Concluído')
    print("Tempo total: %s segundos ---" % end)
示例#14
0
def sample_test(error_list):
        error_list.append(Picture(run_test("./samples/x_0_y_1.27.jpg",False,'test_rig'),
                                  "./samples/x_0_y_1.27.jpg",
                                  "Normal 5 Light",
                                  0))
	error_list.append(Picture(run_test("./samples/small_blob.jpg",False,'test_rig'),
                           "./samples/small_blob.jpg",
                           "Normal 5 Light",
                           0))
	error_list.append(Picture(run_test("./samples/2014-02-27--18-15-03-62.jpg",False,'test_rig'),
                           "./samples/2014-02-27--18-15-03-62.jpg",
                           "Normal 5 Light",
                           0))
	error_list.append(Picture(run_test("./samples/2014-02-27--18-16-34-97.jpg",False,'test_rig'),
                           "./samples/2014-02-27--18-16-34-97.jpg",
                           "Normal 5 Light",
                           0))
	error_list.append(Picture(run_test("./samples/4908_CBAD.jpg",False,'test_rig'),
                           "./samples/4908_CBAD.jpg",
                           "Normal 5 Light",
                           0))
	error_list.append(Picture(run_test("./samples/mirror1.jpg",False,'test_rig'),
                           "./samples/mirror1.jpg",
                           "Normal 5 Light",
                           0))
	error_list.append(Picture(run_test("./samples/mirror2.jpg",False,'test_rig'),
                           "./samples/mirror2.jpg",
                           "Normal 5 Light",
                           0))
	error_list.append(Picture(run_test("./samples/mirror3.jpg",False,'test_rig'),
                           "./samples/mirror3.jpg",
                           "Normal 5 Light",
                           0))
#	freq_list.append(Picture(0,run_test("./samples/4908_IFJE.jpg",True)))
#  freq_list.append(Picture(0,run_test("./samples/4908_ADGH.jpg",True)))
#  freq_list.append(Picture(error= run_test("./samples/1K_1.jpg",True)))
#  freq_list.append(Picture(error= run_test("./samples/4908_SKQP",True)))
#  freq_list.append(Picture(0,run_test("./samples/compressed.jpg",True)))
	return error_list
overall_accuracy_arr = []
paccuracy_arr = []
naccuracy_arr = []

label=open('label').readline().strip()
net=open('net').readline().strip()
maxiter=0

# read maxiter
for i in open('{}-solver.prototxt'.format(net)):
	l = i.split(':')
	if l[0].strip() == 'max_iter':
		maxiter = int(l[1].split('#')[0].strip())
		break

for i in range(3):
	netfn = '{}-{}.prototxt'.format(net,i)
	weightfn = '{}_{}_iter_{}.caffemodel'.format(net,i,maxiter)
	testdbfn = 'data-{}.h5'.format(i)
	overall_accuracy,paccuracy,naccuracy = run_test(netfn,weightfn,testdbfn,label)
	print 'cross validation:',i,'\toverall accuracy:',overall_accuracy,'\t++ rate:', paccuracy,'\t-- rate:', naccuracy
	overall_accuracy_arr.append(overall_accuracy)
	paccuracy_arr.append(paccuracy)
	naccuracy_arr.append(naccuracy)

print '\nSummary:'
print 'overall accuracy:',sum(overall_accuracy_arr)/len(overall_accuracy_arr)
print '++ rate:',sum(paccuracy_arr)/len(paccuracy_arr)
print '-- rate:',sum(naccuracy_arr)/len(naccuracy_arr)
示例#16
0
def dist_TX3K_test(freq_list,path):
	init_len = len(freq_list)
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_1.jpg",
                           "TX3K, .5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_1.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_2.jpg",
                           "TX3K, .5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_2.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_3.jpg",
                           "TX3K, .5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_3.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_4.jpg",
                           "TX3K, .5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_4.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_5.jpg",
                           "TX3K, .5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_5.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_6.jpg",
                           "TX3K, .5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_6.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_7.jpg",
                           "TX3K, .5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_7.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_8.jpg",
                           "TX3K, .5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_8.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_9.jpg",
                           "TX3K, .5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/0.5m/0.5m_9.jpg",True,'test_rig')))
	
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1m/1m_1.jpg",
                           "TX3K, 1m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1m/1m_1.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1m/1m_2.jpg",
                           "TX3K, 1m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1m/1m_2.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1m/1m_3.jpg",
                           "TX3K, 1m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1m/1m_3.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1m/1m_4.jpg",
                           "TX3K, 1m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1m/1m_4.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1m/1m_5.jpg",
                           "TX3K, 1m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1m/1m_5.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1m/1m_6.jpg",
                           "TX3K, 1m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1m/1m_6.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1m/1m_7.jpg",
                           "TX3K, 1m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1m/1m_7.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1m/1m_8.jpg",
                           "TX3K, 1m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1m/1m_8.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1m/1m_9.jpg",
                           "TX3K, 1m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1m/1m_9.jpg",True,'test_rig')))

	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_1.jpg",
                           "TX3K, 1.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_1.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_2.jpg",
                           "TX3K, 1.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_2.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_3.jpg",
                           "TX3K, 1.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_3.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_4.jpg",
                           "TX3K, 1.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_4.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_5.jpg",
                           "TX3K, 1.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_5.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_6.jpg",
                           "TX3K, 1.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_6.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_7.jpg",
                           "TX3K, 1.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_7.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_8.jpg",
                           "TX3K, 1.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_8.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_9.jpg",
                           "TX3K, 1.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/1.5m/1.5m_9.jpg",True,'test_rig')))

	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2m/2m_1.jpg",
                           "TX3K, 2m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2m/2m_1.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2m/2m_2.jpg",
                           "TX3K, 2m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2m/2m_2.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2m/2m_3.jpg",
                           "TX3K, 2m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2m/2m_3.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2m/2m_4.jpg",
                           "TX3K, 2m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2m/2m_4.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2m/2m_5.jpg",
                           "TX3K, 2m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2m/2m_5.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2m/2m_6.jpg",
                           "TX3K, 2m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2m/2m_6.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2m/2m_7.jpg",
                           "TX3K, 2m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2m/2m_7.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2m/2m_8.jpg",
                           "TX3K, 2m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2m/2m_8.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2m/2m_9.jpg",
                           "TX3K, 2m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2m/2m_9.jpg",True,'test_rig')))

	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_1.jpg",
                           "TX3K, 2.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_1.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_2.jpg",
                           "TX3K, 2.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_2.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_3.jpg",
                           "TX3K, 2.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_3.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_4.jpg",
                           "TX3K, 2.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_4.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_5.jpg",
                           "TX3K, 2.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_5.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_6.jpg",
                           "TX3K, 2.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_6.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_7.jpg",
                           "TX3K, 2.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_7.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_8.jpg",
                           "TX3K, 2.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_8.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_9.jpg",
                           "TX3K, 2.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/2.5m/2.5m_9.jpg",True,'test_rig')))

	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3m/3m_1.jpg",
                           "TX3K, 3m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3m/3m_1.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3m/3m_2.jpg",
                           "TX3K, 3m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3m/3m_2.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3m/3m_3.jpg",
                           "TX3K, 3m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3m/3m_3.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3m/3m_4.jpg",
                           "TX3K, 3m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3m/3m_4.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3m/3m_5.jpg",
                           "TX3K, 3m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3m/3m_5.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3m/3m_6.jpg",
                           "TX3K, 3m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3m/3m_6.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3m/3m_7.jpg",
                           "TX3K, 3m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3m/3m_7.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3m/3m_8.jpg",
                           "TX3K, 3m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3m/3m_8.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3m/3m_9.jpg",
                           "TX3K, 3m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3m/3m_9.jpg",True,'test_rig')))

	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_1.jpg",
                           "TX3K, 3.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_1.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_2.jpg",
                           "TX3K, 3.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_2.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_3.jpg",
                           "TX3K, 3.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_3.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_4.jpg",
                           "TX3K, 3.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_4.jpg",True,'test_rig')))
#	freq_list.append(Picture(0,run_test(path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_5.jpg",True)))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_6.jpg",
                           "TX3K, 3.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_6.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_7.jpg",
                           "TX3K, 3.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_7.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_8.jpg",
                           "TX3K, 3.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_8.jpg",True,'test_rig')))
	freq_list.append(Picture(0,
                           path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_9.jpg",
                           "TX3K, 3.5m, 1 Light Source",
                           run_test(path + "/vlc/back_camera/distance/TX3K/3.5m/3.5m_9.jpg",True,'test_rig')))

	i = init_len
	while i < len(freq_list):
		freq_list[i].freq_diff = freq_list[i].freq_diff - 3000
		i = i + 1
	return freq_list
示例#17
0
import os

from test import clean_output, run_test

if __name__ == "__main__":

    output_dir = "output"
    clean_output(output_dir)

    tests = [f for f in os.listdir("../demo/") if f.endswith(".py")]
    print("Found %d tests" % len(tests))

    # Step into output directory
    os.chdir(output_dir)

    failures = []

    for test in tests:
        run_test(test, generate_reference=1)
示例#18
0
        elif d is None:
            return 'null'
        else:
            return unicode(d)


    def __dump_list(self, l):
        '''dump list l into string format of json'''
        assert(isinstance(l, list))
        sep = u', ' if self.space_between_seq else u','
        return '[%s]' % (sep.join((self.__dump_one_object(o) for o in l)))


    def __dump_dict(self, d):
        '''dump dict d into string format of json'''
        assert(isinstance(d, dict))
        sep = u', ' if self.space_between_seq else u','
        return '{%s}' % (sep.join((self.__dump_str(k) + u':' + self.__dump_one_object(v) for k,v in d.items())))


    def __dump_str(self, s):
        '''dump unicode s into string format of json'''
        assert(isinstance(s, unicode))
        res = u''.join((self.dump_back_slash[c] if c in self.dump_back_slash else c for c in s))
        return '"%s"' % res


if __name__ == '__main__':
    import test
    test.run_test()
示例#19
0
        # if epoch % opt.save_epoch_freq == 0:
        #    print('saving the model at the end of epoch %d, iters %d' %
        #          (epoch, total_steps))
        #    model.save_network('latest')
        #    model.save_network(epoch)
        # writer.plot(epoch, "train", dataset.dataset.dataset.classes)
        print('End of epoch %d / %d \t Time Taken: %d sec' %
              (epoch, opt.niter + opt.niter_decay,
               time.time() - epoch_start_time))
        wandb.log({"Epoch elapsed time": time.time() - epoch_start_time},
                  step=epoch)
        model.update_learning_rate()
        model.save_network('latest')
        # need to re run test on train dataset because otherwise results are weird
        run_test(dataset, epoch, "train")
        prec = run_test(val_dataset, epoch, "internal_val")
        # prec = run_test(None, epoch)

        #  Save best model and best prediction
        if prec > best_prec:
            best_prec = prec
            model.save_network('best')
            epoch_no_improve = 0
        else:
            # Early stopping
            epoch_no_improve += 1
            if epoch_no_improve == opt.patience:
                model.load_network("best")
                model.save_network('latest')
                wandb.run.summary[
示例#20
0
文件: dv.py 项目: wehu/pydv
 def body():
     res = run_test(*opts.test, action=opts.action, where=opts.where)
     if type(res) == GeneratorType:
         yield from res
     return res
示例#21
0
def full_box_test(error_list):#add in testing suite of box test to shed-data
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/1.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/1.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/2.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/2.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/3.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/3.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/4.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/4.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/5.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/5.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/6.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/6.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/7.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/7.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/8.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/8.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/9.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/9.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/10.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/10.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/11.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/11.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/12.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/12.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/13.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/13.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/14.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/14.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/15.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/15.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/16.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/16.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/17.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/17.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/18.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/18.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/19.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/19.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   """
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/20.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/20.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/21.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/21.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/22.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/22.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/23.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/23.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/24.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/24.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/25.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/25.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/26.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/26.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/27.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/27.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   error_list.append(Picture(run_test("/home/noah/lab/box_light/full/28.jpg",False,'box'),
                     "/home/noah/lab/box_light/full/28.jpg",
                     "full 4 light image close up 1,2,2.46,3 k freq",
                     0))
   """
   return error_list
示例#22
0
            print('saving the model at the end of epoch %d, iters %d' %
                  (epoch, total_steps))
            model.save_network('latest')
            model.save_network(epoch)

        # Plot training loss per epoch on tensorboard
        writer.plot_epoch_loss(train_loss_epoch / len(dataset), epoch)

        print('End of epoch %d / %d \t Time Taken: %d sec' %
              (epoch, opt.niter + opt.niter_decay + opt.epoch_count,
               time.time() - epoch_start_time))
        if opt.verbose_plot:
            writer.plot_model_wts(model, epoch)

        if epoch % opt.run_test_freq == 0:
            acc = run_test(epoch)

            # Track the best model
            if opt.dataset_mode == 'regression' and acc < best_val_reg_acc:
                best_val_reg_acc = acc
                best_epoch = epoch
            elif opt.dataset_mode in ('classification', 'binary_class'
                                      ) and acc > best_val_cls_acc:
                best_val_cls_acc = acc
                best_epoch = epoch

            writer.plot_acc(acc, epoch)
        lr = model.update_learning_rate(acc, epoch)
        writer.plot_lr(lr, epoch)

    # At end of training, run the last model on the test set
示例#23
0
  """
  A definition test case.
  """
  def test_create_network(self):
    """
    Tests creating a network.
    """
    network = vertigo.create_network("test")
    self.assert_equals("test", network.address)
    network.address = "foo"
    self.assert_equals("foo", network.address)
    network.enable_acking()
    self.assert_true(network.acking_enabled())
    network.disable_acking()
    self.assert_false(network.acking_enabled())
    network.num_ackers = 10
    self.assert_equals(10, network.num_ackers)
    network.ack_expire = 50000
    self.assert_equals(50000, network.ack_expire)
    component = network.from_verticle('test_feeder_verticle', main='test_feeder_verticle.py')
    self.assert_equals('test_feeder_verticle', component.name)
    self.assert_equals('test_feeder_verticle.py', component.main)
    component.workers = 4
    self.assert_equals(4, component.workers)
    component2 = component.to_verticle('test_worker_verticle')
    component2.main = 'test_worker_verticle.py'
    self.assert_equals('test_worker_verticle.py', component2.main)
    self.complete()

run_test(DefinitionTestCase())
示例#24
0
        print('TRAIN ACC [%.3f]'%(writer.acc))
        writer.plot_train_acc(writer.acc, epoch)
        if epoch % opt.save_epoch_freq == 0:
            print('saving the model at the end of epoch %d, iters %d' %
                  (epoch, total_steps))
            model.save_network('latest_net')
            # model.save_network('epoch_%d' % (epoch))


        model.update_learning_rate()
        if opt.verbose_plot:
            writer.plot_model_wts(model, epoch)

        if epoch % opt.run_test_freq == 0:
            acc = run_test(opt.test_data, epoch)
            writer.plot_acc(acc, epoch)

            logger.info('Loss: %f, Acc: %f', loss, acc)
            logger.info('IndexError count - train: %d', heappop_error_train)
            print('End of epoch %d / %d \t Time Taken: %d sec' %
                  (epoch, opt.niter + opt.niter_decay, time.time() - epoch_start_time))
            logger.info('End of epoch %d / %d \t Time Taken: %d sec',
                        epoch, opt.niter + opt.niter_decay, time.time() - epoch_start_time)

            if (acc >= best_tst_acc) and epoch > 5:
                best_tst_acc = acc
                model.save_network('%.6f-%04d' % (acc, epoch))
                print('Saving model....')

示例#25
0
            model.set_input_data(data)
            model.optimize()
            running_loss += model.loss_val
            if total_steps % opt.frequency == 0:
                loss_val = running_loss / opt.frequency
                writer.print_loss(epoch, count, loss_val)
                writer.plot_loss(epoch, count, loss_val, len(dataset))
                running_loss = 0

            if i % opt.loop_frequency == 0:
                print('saving the latest model (epoch %d, total_steps %d)' %
                      (epoch, total_steps))
                model.save_network('latest')
            # break

        if epoch % opt.epoch_frequency == 0:
            print('saving the model at the end of epoch %d, iters %d' %
                  (epoch, total_steps))
            if (epoch - 1) % 20 == 0:
                model.log_history_and_plot(writer, epoch, count)
                model.log_features_and_plot(epoch, count)
            model.save_network('latest')
            model.save_network(epoch)

        if epoch % opt.test_frequency == 0:
            acc = run_test(epoch)
            writer.plot_acc(acc, epoch)
        # break
    wait = input("input")
    writer.close()
示例#26
0
    for i in range(size):
        settings.clusters[i].level = labels[i]
        nodes.append({
            "id": settings.clusters[i].get_name(),
            "group": labels[i],
            "size": len(settings.clusters[i].funcs) + 2
        })

    links = []
    for i in range(size):
        for j in range(i + 1, size):
            if settings.links[i][j] != 0:
                links.append({
                    "source": settings.clusters[i].get_name(),
                    "target": settings.clusters[j].get_name(),
                    "value": settings.links[i][j] * 5
                })

    data = {"nodes": nodes, "links": links}
    store2json('miserables2.json', data)


if __name__ == '__main__':
    test.run_test()

    test.print_links()
    test.print_clusters()

    labels = get_random_labels()
    generate_force_layout(labels)
def main():
    opt = TrainOptions().parse()
    if opt == None:
        return

    dataset = DataLoader(opt)
    dataset_size = len(dataset) * opt.num_grasps_per_object
    model = create_model(opt)
    writer = Writer(opt)
    total_steps = 0
    for epoch in range(opt.epoch_count, opt.niter + opt.niter_decay + 1):
        epoch_start_time = time.time()
        iter_data_time = time.time()
        epoch_iter = 0
        for i, data in enumerate(dataset):
            iter_start_time = time.time()
            if total_steps % opt.print_freq == 0:
                t_data = iter_start_time - iter_data_time
            total_steps += opt.batch_size
            epoch_iter += opt.batch_size
            model.set_input(data)
            model.optimize_parameters()
            if total_steps % opt.print_freq == 0:
                loss_types = []
                if opt.arch == "vae":
                    loss = [
                        model.loss, model.kl_loss, model.reconstruction_loss,
                        model.confidence_loss, model.l2_loss
                    ]
                    loss_types = [
                        "total_loss", "kl_loss", "reconstruction_loss",
                        "confidence loss", "l2_loss"
                    ]
                elif opt.arch == "gan":
                    loss = [
                        model.loss, model.reconstruction_loss,
                        model.confidence_loss
                    ]
                    loss_types = [
                        "total_loss", "reconstruction_loss", "confidence_loss"
                    ]
                else:
                    loss = [
                        model.loss, model.classification_loss,
                        model.confidence_loss
                    ]
                    loss_types = [
                        "total_loss", "classification_loss", "confidence_loss"
                    ]
                t = (time.time() - iter_start_time) / opt.batch_size
                writer.print_current_losses(epoch, epoch_iter, loss, t, t_data,
                                            loss_types)
                writer.plot_loss(loss, epoch, epoch_iter, dataset_size,
                                 loss_types)

            if i % opt.save_latest_freq == 0:
                print('saving the latest model (epoch %d, total_steps %d)' %
                      (epoch, total_steps))
                model.save_network('latest', epoch)

            iter_data_time = time.time()

        if epoch % opt.save_epoch_freq == 0:
            print('saving the model at the end of epoch %d, iters %d' %
                  (epoch, total_steps))
            model.save_network('latest', epoch)
            model.save_network(str(epoch), epoch)

        print('End of epoch %d / %d \t Time Taken: %d sec' %
              (epoch, opt.niter + opt.niter_decay,
               time.time() - epoch_start_time))
        model.update_learning_rate()
        if opt.verbose_plot:
            writer.plot_model_wts(model, epoch)

        if epoch % opt.run_test_freq == 0:
            acc = run_test(epoch, name=opt.name)
            writer.plot_acc(acc, epoch)

    writer.close()
示例#28
0
    network = self._create_fail_network('test_failing_polling_feeder.py')
    cluster = LocalCluster()
    def deploy_handler(error, context):
      self.assert_null(error)
      self.assert_not_null(context)
    cluster.deploy(network, deploy_handler)

  def test_stream_feeder_ack(self):
    """
    Tests the stream feeder acking support.
    """
    network = self._create_ack_network('test_acking_stream_feeder.py')
    cluster = LocalCluster()
    def deploy_handler(error, context):
      self.assert_null(error)
      self.assert_not_null(context)
    cluster.deploy(network, deploy_handler)

  def test_stream_feeder_fail(self):
    """
    Tests the stream feeder fail support.
    """
    network = self._create_fail_network('test_failing_stream_feeder.py')
    cluster = LocalCluster()
    def deploy_handler(error, context):
      self.assert_null(error)
      self.assert_not_null(context)
    cluster.deploy(network, deploy_handler)

run_test(FeederTestCase())
示例#29
0
                                                amount=pruning_percentage)


# Control Seed
# torch.manual_seed(args.seed)

# Select Device
use_cuda = not args.no_cuda and torch.cuda.is_available()
device = torch.device("cuda" if use_cuda else 'cpu')
if use_cuda:
    print("Using CUDA!")
    torch.cuda.manual_seed(args.seed)
else:
    print('Not using CUDA!!!')

model = test.run_test(args.model, 1)

# NOTE : `weight_decay` term denotes L2 regularization loss term
# optimizer = optim.Adam(model.parameters(), lr=args.lr, weight_decay=0.0001)
# initial_optimizer_state_dict = optimizer.state_dict()

# model.prune_by_std(args.sensitivity)

# Pruning
# print("--- Before pruning ---")
# prune_darts(model, var1)

for i2 in [0.25, 0.30, 0.40, 0.5, 0.6, 0.7, 0.8, 0.9]:
    model = test.run_test(args.model, 1)
    prune_darts(model, i2)
    print("--- Quantization --- ")
示例#30
0
            cluster.deploy_network(network, handler=deploy_handler)
        vertigo.deploy_cluster('test_basic_send', handler=cluster_handler)

    def test_group_send(self):
        """Test sending group messages between two components."""
        network = vertigo.create_network('test-group')
        network.add_verticle('sender', main='test_group_sender.py')
        network.add_verticle('receiver', main='test_group_receiver.py')
        network.create_connection(('sender', 'out'), ('receiver', 'in'))
        def cluster_handler(error, cluster):
            self.assert_null(error)
            def deploy_handler(error, network):
                self.assert_null(error)
            cluster.deploy_network(network, handler=deploy_handler)
        vertigo.deploy_cluster('test_group_send', handler=cluster_handler)

    def test_batch_send(self):
        """Test sending batch messages between two components."""
        network = vertigo.create_network('test-batch')
        network.add_verticle('sender', main='test_batch_sender.py')
        network.add_verticle('receiver', main='test_batch_receiver.py')
        network.create_connection(('sender', 'out'), ('receiver', 'in'))
        def cluster_handler(error, cluster):
            self.assert_null(error)
            def deploy_handler(error, network):
                self.assert_null(error)
            cluster.deploy_network(network, handler=deploy_handler)
        vertigo.deploy_cluster('test_batch_send', handler=cluster_handler)

run_test(NetworkTestCase())
示例#31
0
        val_vec.append(running_loss_val)

        if ckpt and np.sum(
                np.asarray(val_vec) > running_loss_val) == len(val_vec) - 1:
            print('Making check point - Best')
            torch.save(model.state_dict(),
                       os.path.join(save_dir, dir_name, 'best.pkl'))

        print('Epoch:', epoch + 1, '|| Total loss validation:',
              running_loss_val)
        try:
            if epoch % 1 == 0:
                j = run_test(model=model,
                             dataloader=val_dataloader,
                             path=join(save_dir, dir_name),
                             device=device,
                             save=False)
                J.append(j)
        except:
            J.append([0 for i in range(25)])

except KeyboardInterrupt:
    print('Training stopped by KeyboardInterrupt')
except:
    1 + 1
    print('=======================================')
    print('             Error found')
    print('=======================================')
    raise
示例#32
0
def runme():
    if (len(sys.argv) > 1 and sys.argv[1] == "fill"):
        run_model()
        run_test()
    port = int(os.environ.get('PORT', 5000))
    app.run(debug=True, port=port, host='0.0.0.0')
示例#33
0
from net.huffmancoding import huffman_encode_model
import test
import util

parser = argparse.ArgumentParser(
    description='Huffman encode a quantized model')
parser.add_argument(
    '--model',
    type=str,
    default=
    '../cnn/eval-EXP-20200415-092238/model_after_weight_sharing.ptmodel',
    help='saved quantized model')
parser.add_argument('--no-cuda',
                    action='store_true',
                    default=False,
                    help='disables CUDA')
parser.add_argument(
    '--output',
    default='saves/model_after_pruning_and_quantization.ptmodel',
    type=str,
    help='path to model output')
args = parser.parse_args()

use_cuda = not args.no_cuda and torch.cuda.is_available()
device = torch.device("cuda" if use_cuda else 'cpu')

model = test.run_test(args.output, 2)

# model = torch.load(args.model)
huffman_encode_model(model)