Add image segmentation support to GUI#609
Open
tejasstanley wants to merge 11 commits into
Open
Conversation
dpascualhe
requested changes
Jul 10, 2026
| st.info(f"{dataset_type} image segmentation viewer is not wired yet.") | ||
|
|
||
|
|
||
| def _render_cityscapes_viewer(): |
Collaborator
There was a problem hiding this comment.
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, | ||
| ) |
Collaborator
There was a problem hiding this comment.
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 = [ |
| st.dataframe(_classes_dataframe(dataset.ontology), use_container_width=True) | ||
|
|
||
|
|
||
| def _load_cityscapes_dataset(dataset_path, split): |
Collaborator
There was a problem hiding this comment.
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
This was referenced Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR extends the GUI structure to support image segmentation alongside the existing image detection flow.
Changes include: