Ilastik object classification headless on Windows 10

Sample code

run-ilastik.bat --headless 
--project path\to\the\project.ilp
    --export_dtype float32
    --export_source="object indentities"
    --output_format="multipage tiff"


ERROR 2021-01-14 16:58:50,100 log_exception 3068 14032 Traceback (most recent call last):
File "C:\Program Files\ilastik-1.3.3post3\ilastik-meta\ilastik\ilastik\shell\", line 467, in _loadProject
File "C:\Program Files\ilastik-1.3.3post3\ilastik-meta\ilastik\ilastik\workflows\objectClassification\", line 352, in onProjectLoaded
File "C:\Program Files\ilastik-1.3.3post3\ilastik-meta\ilastik\ilastik\applets\batchProcessing\", line 64, in run_export_from_parsed_args
return self.run_export(role_path_dict, parsed_args.input_axes, sequence_axis=parsed_args.stack_along)
File "C:\Program Files\ilastik-1.3.3post3\ilastik-meta\ilastik\ilastik\applets\batchProcessing\", line 118, in run_export
progress_callback=partial(lerpProgressSignal, global_progress_start, global_progress_end),
File "C:\Program Files\ilastik-1.3.3post3\ilastik-meta\ilastik\ilastik\applets\batchProcessing\", line 180, in export_dataset"Exporting to {opDataExport.ExportPath.value}")
File "C:\Program Files\ilastik-1.3.3post3\ilastik-meta\lazyflow\lazyflow\", line 1015, in value
temp = self[:].wait()
File "C:\Program Files\ilastik-1.3.3post3\ilastik-meta\lazyflow\lazyflow\", line 958, in __getitem__
raise Slot.SlotNotReadyError(slotInfoMsg)
lazyflow.slot.Slot.SlotNotReadyError: Can't get data from slot <class 'ilastik.utility.opMultiLaneWrapper.OpMultiLaneWrapper'>.ExportPath yet. It isn't ready.First upstream problem slot is: OpExportSlot/OpExportSlot.Input []:       {_ready : False, shape : None, has_mask : None, _dirty : True}

ERROR 2021-01-14 16:58:50,102 log_exception 3068 14032 Project could not be loaded due to the exception shown above.


I am trying to run this command from Windows terminal.
I already succeed in generating Simple_Segmentation_multipage.tiff and Picture_Probabilities.h5 with other previous commands.

Analysis goals

I am not sure how to provide this extra information (probabilities) and how to get an object_identities_multipage.tiff file as output.

I already did it manually successfully through the GUI but I would like to do it in the headless mode.


  • How can I provide object identities as output_source? From the documentation doesn’t seem possible but from the GUI in Ilastik it is.

  • The dtype is set up to float32 because is the only way I figured out to be able to export a multipage tiff file with the labels on it.

Thank you in advance to everyone!

Best regards,

I found the solution. This works when run-ilastik.bat is added to path variables in Windows.

run-ilastik.bat --headless 
--project path/to/the/project_trained.ilp 
--export_dtype float32 
--export_source="Object Identities" 
--output_format "multipage tiff"

For h5 files we won’t need to add output_filename_format and output_format.

run-ilastik.bat --headless 
--project path/to/the/project_trained.ilp 
--export_dtype float32 
--export_source="Object Identities" 

The problem why it couldn’t work it may be that I was using Jupyter notebook to run all these commands looping through the files using differents projects and concatenating their results.
Here there is a small example to those who want to run it from Python.

from Pathlib import Path
import subprocess

ilastik_location = Path(r"C:\Program Files\ilastik-1.3.3post3")
project_location = Path(r"path\to\the\projectsfolder")
input_dir = Path(r"path\to\the\rawimages")
input_files = [i for i in list(input_dir.glob("*tif")) if "Probabilities" not in i.stem]

probabilities = list(input_dir.glob("*Probabilities*tif")) # These Probabilities were generated previously with other Project

# os.chdir(ilastik_location) # NOT required if ilastik has been added to PATH in environtment variables

ilastik = "run-ilastik.bat --headless"
project_name = Path(r"Project_trained.ilp")
project = "--project {}".format(project_location / project_name)
export_source = """--export_source="Object Identities" """ 
export_dtype = "--export_dtype float32"
input_axes = "--input_axes=zyx"

# For tiff output
output_filename = """--output_filename_format="{dataset_dir}/{nickname}_{result_type}.tiff" """
output_format = """--output_format "multipage tiff" """

# # For h5 output
# output_filename = """--output_filename_format="{dataset_dir}/{nickname}_{result_type}.h5" """
# output_format = ""

for ix, fl in enumerate(tqdm(input_files)):
    raw_data = """--raw_data="{}" """.format(fl)
    probs = """--prediction_maps="{}" """.format(probabilities[ix])
    command = " ".join([str(ilastik), project, raw_data, probs, input_axes, export_dtype, 
                        export_source, output_filename, output_format])
    command = command.replace("  ", " ") # This any double space placed by mistake
    print(command, "\n"), shell=True)

Sorry for the late reply. Please use ilastik.exe instead of ilastik.bat. Then it should work…

It is even a bit more safe than adding the ilastik directory to the path. With the path solution you might still find conflicting libraries on your system…

1 Like