Skip to content

Commit

Permalink
feat: output mask as part of execution for fishial
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Nov 13, 2024
1 parent ac25d01 commit ec1de42
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fishsense_lite/commands/label_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def execute_fishial(
):
device = "cuda" if torch.cuda.is_available() else "cpu"
output_file = get_output_file(input_file, root, output, "jpg")
mask_file = (
output_file.parent
/ f"{output_file.name.removesuffix(output_file.suffix)}.mask.png"
)
json_file = output_file.with_suffix(".json")

if output_file.exists() and json_file.exists() and not overwrite:
Expand All @@ -100,6 +104,11 @@ def execute_fishial(
output_file.parent.mkdir(parents=True, exist_ok=True)
cv2.imwrite(output_file.absolute().as_posix(), image)

debug_output = (segmentations.astype(float) / segmentations.max() * 255).astype(
np.uint8
)
cv2.imwrite(mask_file.absolute().as_posix(), debug_output)

json_objects = SegmentationLabelStudioJSON(
f"{prefix}{output_file.relative_to(output.absolute()).as_posix()}",
segmentations,
Expand Down

0 comments on commit ec1de42

Please sign in to comment.