Exemplo n.º 1
0
def show_stack_info(model):
    p = Plotter(ax_num=4)
    lb = LabelBinarizer()
    #load spectrum
    spec = np.load(args['stack'])[args['index']]
    #classify spectrum
    p1, p2, p_stack = classify(model, spec, lb)

    #load true stack parameters
    name = args['stack'].split("/")[-1][:-4]
    batch_dir_list = args['stack'].split("/")[:-2]
    batch_dir = ""
    for f in batch_dir_list:
        batch_dir += f
        batch_dir += "/"

    with open(f"{batch_dir}params/{name}.pickle", "rb") as f:
        stack_params = pickle.load(f)

    t1, t2, t_stack = stack_params[args['index']]

    pred_text = p.write_text(p1, p2, p_stack, loss_val=0)
    true_text = p.write_text(t1, t2, t_stack, loss_val=0)
    p.double_spec(spec, pred_text, true_text)
    plt.show()
Exemplo n.º 2
0
def NN_test_loop(crawler, lb):

    while True:
        while True:
            spectrum, true1, true2, true_stack = create_random_stack(
                crawler, param_dict)

            if np.max(spectrum) > 0.1:
                break

        l1, l2, stack = classify(model, spectrum, lb)

        plotter = Plotter(ax3_on=True)
        pred_text = plotter.write_text(l1, l2, stack, loss_val=0)
        true_text = plotter.write_text(true1, true2, true_stack, loss_val=0)
        plotter.double_text(spectrum, pred_text, true_text)
        plt.show()