Skip to content
Snippets Groups Projects
Commit 5aca68af authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Needed to make copy of project file

parent 5125d44c
No related branches found
No related tags found
No related merge requests found
...@@ -203,7 +203,7 @@ def compare_object_maps(truth: GenericImageDataAccessor, inferred: GenericImageD ...@@ -203,7 +203,7 @@ def compare_object_maps(truth: GenericImageDataAccessor, inferred: GenericImageD
if __name__ == '__main__': if __name__ == '__main__':
root = Path('c:/Users/rhodes/projects/proj0011-plankton-seg/') root = Path('c:/Users/rhodes/projects/proj0011-plankton-seg/')
template_ilp = root / 'exp0014/template_obj.ilp' template_ilp = root / 'exp0014/template_obj.ilp'
where_patch_stack = root / 'exp0009/output/labeled_patches-20231018-0000' where_patch_stack = root / 'exp0009/output/labeled_patches-20231018-0001'
# auto-populate an object classifier # auto-populate an object classifier
new_ilp = generate_ilastik_object_classifier( new_ilp = generate_ilastik_object_classifier(
...@@ -212,11 +212,11 @@ if __name__ == '__main__': ...@@ -212,11 +212,11 @@ if __name__ == '__main__':
stack_name='train' stack_name='train'
) )
def infer_and_compare(suffix): def infer_and_compare(ilp, suffix):
# infer object labels from the same data used to train the classifier # infer object labels from the same data used to train the classifier
train_zstack_raw = generate_file_accessor(where_patch_stack / 'zstack_train_raw.tif') train_zstack_raw = generate_file_accessor(where_patch_stack / 'zstack_train_raw.tif')
train_zstack_mask = generate_file_accessor(where_patch_stack / 'zstack_train_mask.tif') train_zstack_mask = generate_file_accessor(where_patch_stack / 'zstack_train_mask.tif')
mod = PatchStackObjectClassifier({'project_file': where_patch_stack / new_ilp}) mod = PatchStackObjectClassifier({'project_file': where_patch_stack / ilp})
result_acc, _ = mod.infer(train_zstack_raw, train_zstack_mask) result_acc, _ = mod.infer(train_zstack_raw, train_zstack_mask)
write_accessor_data_to_file(where_patch_stack / f'zstack_train_result_{suffix}.tif', result_acc) write_accessor_data_to_file(where_patch_stack / f'zstack_train_result_{suffix}.tif', result_acc)
...@@ -229,17 +229,22 @@ if __name__ == '__main__': ...@@ -229,17 +229,22 @@ if __name__ == '__main__':
), ),
index=False index=False
) )
print(f'Generated ilastik project {ilp}')
print('Truth and inferred labels match?') print('Truth and inferred labels match?')
print(pd.value_counts(df_comp['truth_label'] == df_comp['inferred_label'])) print(pd.value_counts(df_comp['truth_label'] == df_comp['inferred_label']))
# infer object labels from the same data used to train the classifier # infer object labels from the same data used to train the classifier
infer_and_compare('before') infer_and_compare(new_ilp, 'before')
# prompt user input when ilastik file has been modified in-app # copy project and prompt user input once ilastik file has been modified in-app
print(f'Press enter when project file {new_ilp} has been updated in ilastik') mod_ilp = shutil.copy(
new_ilp,
where_patch_stack / autonumber_new_file(where_patch_stack, 'auto-obj', 'ilp')
)
print(f'Press enter when project file {mod_ilp} has been updated in ilastik')
input() input()
# repeat inference with the same project file, but a fresh model handle # repeat inference with the modified project file
infer_and_compare('after') infer_and_compare(mod_ilp, 'after')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment