diff --git a/wrapper.py b/wrapper.py index 08a294b..f220a2c 100644 --- a/wrapper.py +++ b/wrapper.py @@ -11,8 +11,8 @@ import skimage.segmentation from subprocess import call from cytomine.models import Job -from neubiaswg5 import CLASS_OBJSEG -from neubiaswg5.helpers import NeubiasJob, prepare_data, upload_data, upload_metrics +from biaflows import CLASS_OBJSEG +from biaflows.helpers import BiaflowsJob, prepare_data, upload_data, upload_metrics def label_objects(img, threshold=0.9, min_size=25): @@ -49,10 +49,10 @@ def main(argv): base_path = "{}".format(os.getenv("HOME")) # Mandatory for Singularity problem_cls = CLASS_OBJSEG - with NeubiasJob.from_cli(argv) as nj: - nj.job.update(status=Job.RUNNING, progress=0, statusComment="Initialisation...") + with BiaflowsJob.from_cli(argv) as bj: + bj.job.update(status=Job.RUNNING, progress=0, statusComment="Initialisation...") # 1. Prepare data for workflow - in_imgs, gt_imgs, in_path, gt_path, out_path, tmp_path = prepare_data(problem_cls, nj, **nj.flags) + in_imgs, gt_imgs, in_path, gt_path, out_path, tmp_path = prepare_data(problem_cls, bj, **bj.flags) temp_img = skimage.io.imread(os.path.join(in_path,"{}".format(in_imgs[0].filename))) if len(temp_img.shape) > 2: @@ -62,7 +62,7 @@ def main(argv): convert2rgb(in_imgs) # 2. Run ilastik prediction - nj.job.update(progress=25, statusComment="Launching workflow...") + bj.job.update(progress=25, statusComment="Launching workflow...") shArgs = [ "/app/ilastik/run_ilastik.sh", "--headless", @@ -80,20 +80,20 @@ def main(argv): fn = os.path.join(tmp_path,"{}".format(image.filename)) outfn = os.path.join(out_path,"{}".format(image.filename)) img = skimage.io.imread(fn) - img = label_objects(img, nj.parameters.probability_threshold, nj.parameters.min_size) + img = label_objects(img, bj.parameters.probability_threshold, bj.parameters.min_size) skimage.io.imsave(outfn, img) # 3. Upload data to Cytomine - upload_data(problem_cls, nj, in_imgs, out_path, **nj.flags, monitor_params={ + upload_data(problem_cls, bj, in_imgs, out_path, **bj.flags, monitor_params={ "start": 60, "end": 90, "period": 0.1, "prefix": "Extracting and uploading polygons from masks"}) # 4. Compute and upload metrics - nj.job.update(progress=90, statusComment="Computing and uploading metrics...") - upload_metrics(problem_cls, nj, in_imgs, gt_path, out_path, tmp_path, **nj.flags) + bj.job.update(progress=90, statusComment="Computing and uploading metrics...") + upload_metrics(problem_cls, bj, in_imgs, gt_path, out_path, tmp_path, **bj.flags) # 5. Pipeline finished - nj.job.update(progress=100, status=Job.TERMINATED, status_comment="Finished.") + bj.job.update(progress=100, status=Job.TERMINATED, status_comment="Finished.") if __name__ == "__main__":