Skip to content

Commit

Permalink
Merge pull request #28 from MortenTabaka/Improve_segmentation_with_po…
Browse files Browse the repository at this point in the history
…st_processing

Improve segmentation by implementing post-processing using SLIC algorithm for super pixels. 
Best enhancement is visible in boundaries post-processing.
Further research in best parameters are needed.
  • Loading branch information
MortenTabaka committed May 1, 2023
2 parents 9fc8ca0 + 5bdab2a commit 2b9d0bd
Show file tree
Hide file tree
Showing 12 changed files with 1,004 additions and 175 deletions.
1 change: 1 addition & 0 deletions dockerfile-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ tqdm
requests
PyYAML
typer
scikit-image
39 changes: 33 additions & 6 deletions models/scripts/run_prediction_on_folder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from enum import Enum
from pathlib import Path

import typer

Expand All @@ -22,13 +22,32 @@ def main(
model_revision: AvailableRevisions = typer.Option(
default=AvailableRevisions.version_5_10_2,
help="Choose model revision for predictions.",
show_choices=True
show_choices=True,
),
weights: TypeOfWeightsToLoad = typer.Option(
default=TypeOfWeightsToLoad.miou,
help="Pick which weights load",
show_choices=True
show_choices=True,
),
sp_post_processing: bool = typer.Option(False),
sp_count: int = typer.Option(200, min=0),
sp_compactness: float = typer.Option(10, min=0),
sp_thresh: float = typer.Option(0.7, min=0, max=1),
border_sp: bool = typer.Option(
True, help="If should post-process tile boundaries with SuperPixels algorithm"
),
border_sp_count: int = typer.Option(
50, min=0, help="Will be multiplied by number of borders in single strip"
),
border_compactness: float = typer.Option(10, min=0),
border_sp_thresh: float = typer.Option(0.3, min=0, max=1),
border_sp_class_balance: bool = typer.Option(False),
border_sp_pixel_range: int = typer.Option(
50,
min=1,
help="Strip width in single direction. Stripe width will be double of the value.",
),
clear_cache: bool = typer.Option(True),
input_folder: Path = typer.Option(
get_absolute_path_to_project_location("models/custom_data/input"),
help='Default: "models/custom_data/input". '
Expand All @@ -44,14 +63,22 @@ def main(
dir_okay=True,
show_default=False,
),
clear_cache: bool = typer.Option(True),
) -> None:

PredictionPipeline(
model_revision=model_revision,
input_folder=input_folder,
output_folder=output_folder,
which_metric_best_weights_to_load=weights
which_metric_best_weights_to_load=weights,
tiles_superpixel_postprocessing=sp_post_processing,
number_of_superpixels=sp_count,
compactness=sp_compactness,
superpixel_threshold=sp_thresh,
border_sp=border_sp,
border_sp_count=border_sp_count,
border_compactness=border_compactness,
border_sp_thresh=border_sp_thresh,
border_sp_class_balance=border_sp_class_balance,
border_sp_pixel_range=border_sp_pixel_range,
).process(clear_cache)


Expand Down

0 comments on commit 2b9d0bd

Please sign in to comment.