Skip to content

Add image segmentation support to GUI#609

Open
tejasstanley wants to merge 11 commits into
JdeRobot:masterfrom
tejasstanley:feat/GUI_visual_detection
Open

Add image segmentation support to GUI#609
tejasstanley wants to merge 11 commits into
JdeRobot:masterfrom
tejasstanley:feat/GUI_visual_detection

Conversation

@tejasstanley

Copy link
Copy Markdown
Collaborator

This PR extends the GUI structure to support image segmentation alongside the existing image detection flow.
Changes include:

  • Adds task-specific image segmentation sidebar, dataset viewer, inference, and evaluator tabs.
  • Adds Cityscapes support for the image segmentation GUI.
  • Adds shared GUI utilities under tabs/tasks/utils.py.
  • Moves browse helpers out of perceptionmetrics/utils/gui.py.
  • Uses TorchImageSegmentationModel for segmentation inference and evaluation.
  • Adds live evaluation progress callbacks for segmentation evaluation.

@tejasstanley tejasstanley marked this pull request as ready for review July 6, 2026 14:20
st.info(f"{dataset_type} image segmentation viewer is not wired yet.")


def _render_cityscapes_viewer():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is a different _render*viewer needed per dataset? I can buy that the loading logic might be different, but the rendering should be done the same across datasets

Comment on lines +41 to +95
if dataset_type == "Cityscapes":
roots = {"train": None, "val": None, "test": None}
roots[split] = dataset_path
dataset_key = (
"cityscapes_segmentation_evaluation_dataset",
os.path.abspath(dataset_path),
split,
st.session_state.get(
"segmentation_image_dir",
"leftImg8bit_trainvaltest/leftImg8bit",
),
st.session_state.get("segmentation_label_dir", "gtFine"),
st.session_state.get(
"segmentation_image_suffix", "_leftImg8bit.png"
),
st.session_state.get(
"segmentation_label_suffix", "_gtFine_labelIds.png"
),
st.session_state.get("segmentation_use_train_id", False),
)

if dataset_key not in st.session_state:
st.session_state[dataset_key] = CityscapesImageSegmentationDataset(
train_dataset_root=roots["train"],
val_dataset_root=roots["val"],
test_dataset_root=roots["test"],
image_dir=dataset_key[3],
label_dir=dataset_key[4],
image_suffix=dataset_key[5],
label_suffix=dataset_key[6],
use_train_id=dataset_key[7],
)
else:
version = st.session_state.get(
"nuimages_segmentation_version", "v1.0-mini"
)
labels_rel_dir = st.session_state.get(
"nuimages_segmentation_labels_dir",
"generated/nuimages_segmentation_labels",
)
dataset_key = (
"nuimages_segmentation_evaluation_dataset",
os.path.abspath(dataset_path),
version,
split,
labels_rel_dir,
)

if dataset_key not in st.session_state:
st.session_state[dataset_key] = NuImagesSegmentationDataset(
dataset_dir=dataset_path,
version=version,
split=split,
labels_rel_dir=labels_rel_dir,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we reuse the loading logic from the dataset_viewer.py to avoid code duplication?

from tabs.tasks.utils import browse_file, browse_folder


IMAGE_SEGMENTATION_DATASETS = [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also GAIA and Generic

st.dataframe(_classes_dataframe(dataset.ontology), use_container_width=True)


def _load_cityscapes_dataset(dataset_path, split):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even for loading I think we could have a single function that takes a constant with a dictionary containing for each dataset choice the class name and a dict with the parameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants