Exemple #1
0
def main(noeval, **args):

    #args should be the info you need to specify the params
    # for a given experiment, but only params should be used below
    params = fill_params(**args)

    utils.set_gpus(params["gpus"])

    net = utils.create_network(**params)
    if not noeval:
        net.eval()

    utils.log_tagged_modules(params["modules_used"], params["log_dir"],
                             params["log_tag"], params["chkpt_num"])

    for dset in params["dsets"]:
        print(dset)

        fs = make_forward_scanner(dset, **params)

        output = forward.forward(net,
                                 fs,
                                 params["scan_spec"],
                                 activation=params["activation"])

        save_output(output, dset, **params)
Exemple #2
0
def main_fwd(noeval, **args):

    #args should be the info you need to specify the params
    # for a given experiment, but only params should be used below
    params = fill_params_fwd(**args)

    utils.set_gpus(params["gpus"])

    net = utils.create_network(**params)
    if not noeval:
        net.eval()

    utils.log_tagged_modules(params["modules_used"], params["log_dir"],
                             params["log_tag"], params["chkpt_num"])

    #lightsheet mods - input folder contains list of our "big" patches
    input_fld = os.path.join(params["data_dir"],
                             "input_patches")  #set directory
    output_fld = os.path.join(params["data_dir"],
                              "cnn_output")  #set patches directory

    if not os.path.exists(output_fld): os.mkdir(output_fld)
    jobid = 0  #for demo only

    #find files that need to be processed
    fls = [os.path.join(input_fld, xx) for xx in os.listdir(input_fld)]
    fls.sort()

    #select the file to process for this batch job
    if jobid > len(fls):
        #essentially kill job if too high - doing this to hopefully help with karma score although might not make a difference
        sys.stdout.write("\njobid {} > number of files {}\n".format(
            jobid, len(fls)))
        sys.stdout.flush()
    else:
        dset = fls[jobid]

        start = time.time()

        fs = make_forward_scanner(dset, **params)
        sys.stdout.write("\striding by: {}".format(fs.stride))
        sys.stdout.flush()

        output = forward.forward(
            net,
            fs,
            params["scan_spec"],  #runs forward pass
            activation=params["activation"])

        save_output(output, dset, output_fld, jobid, params["output_tag"],
                    params["chkpt_num"])  #saves tif
        fs._init()  #clear out scanner

    sys.stdout.write("\patch {}: {} min\n".format(
        jobid + 1, round((time.time() - start) / 60, 1)))
    sys.stdout.flush()
Exemple #3
0
def main(noeval, **args):

    #args should be the info you need to specify the params
    # for a given experiment, but only params should be used below
    params = fill_params(**args)

    utils.set_gpus(params["gpus"])

    net = utils.create_network(**params)
    if not noeval:
        net.eval()

    utils.log_tagged_modules(params["modules_used"], params["log_dir"],
                             params["log_tag"], params["chkpt_num"])

    #lightsheet mods - input folder contains list of our "big" patches
    input_fld = os.path.join(params["data_dir"],
                             "input_chnks")  #set patches directory
    sys.stdout.write("running inference on: \n{}\n".format(
        os.path.basename(params["data_dir"])))
    sys.stdout.flush()
    output_fld = os.path.join(params["data_dir"],
                              "output_chnks")  #set output directory

    jobid = int(params["jobid"])  #set patch no. to run through cnn

    #find files that need to be processed
    fls = [os.path.join(input_fld, xx) for xx in os.listdir(input_fld)]
    fls.sort()

    #select the file to process for this array job
    if jobid > len(fls) - 1:
        sys.stdout.write("\njobid {} > number of files {}".format(
            jobid, len(fls)))
        sys.stdout.flush()
    else:
        start = time.time()
        dset = fls[jobid]

        fs = make_forward_scanner(dset, **params)

        output = forward.forward(
            net,
            fs,
            params["scan_spec"],  #runs forward pass
            activation=params["activation"])

        save_output(output, dset, output_fld, **params)  #saves tif
        fs._init()  #clear out scanner

        sys.stdout.write("patch {}: {} min\n".format(
            jobid + 1, round((time.time() - start) / 60, 1)))
        sys.stdout.flush()
def main(**args):

    #args should be the info you need to specify the params
    # for a given experiment, but only params should be used below
    params = fill_params(**args)

    utils.set_gpus(params["gpus"])

    utils.make_required_dirs(**params)

    utils.log_tagged_modules(params["modules_used"],
                             params["log_dir"], "train",
                             chkpt_num=params["chkpt_num"])

    start_training(**params)