diff --git a/plantseg/core/zoo.py b/plantseg/core/zoo.py index fb2d1fc1..f7ec4e20 100644 --- a/plantseg/core/zoo.py +++ b/plantseg/core/zoo.py @@ -1,5 +1,7 @@ """Model Zoo Singleton""" +# pylint: disable=C0116,C0103 + import json import logging from enum import Enum @@ -392,15 +394,23 @@ def refresh_bioimageio_zoo_urls(self): collection_path = Path(pooch.retrieve(BIOIMAGE_IO_COLLECTION_URL, known_hash=None)) with collection_path.open(encoding='utf-8') as f: collection = json.load(f) + + models = [entry for entry in collection["collection"] if entry["type"] == "model"] + max_nickname_length = max(len(entry["nickname"]) for entry in models) + + def truncate_name(name, length=100): + return name[:length] + '...' if len(name) > length else name + + def build_model_url_dict(filter_func=None): + filtered_models = filter(filter_func, models) if filter_func else models + return { + f"{entry['nickname']:<{max_nickname_length}}: {truncate_name(entry['name'])}": entry["rdf_source"] + for entry in filtered_models + } + self._bioimageio_zoo_collection = collection - self._bioimageio_zoo_all_model_url_dict = { - entry["nickname"]: entry["rdf_source"] for entry in collection["collection"] if entry["type"] == "model" - } - self._bioimageio_zoo_plantseg_model_url_dict = { - entry["nickname"]: entry["rdf_source"] - for entry in collection["collection"] - if entry["type"] == "model" and self._is_plantseg_model(entry) - } + self._bioimageio_zoo_all_model_url_dict = build_model_url_dict() + self._bioimageio_zoo_plantseg_model_url_dict = build_model_url_dict(self._is_plantseg_model) def _is_plantseg_model(self, collection_entry: dict) -> bool: """Determines if the 'tags' field in a collection entry contains the keyword 'plantseg'.""" diff --git a/plantseg/viewer_napari/containers.py b/plantseg/viewer_napari/containers.py index b6d7a7f6..6fe55743 100644 --- a/plantseg/viewer_napari/containers.py +++ b/plantseg/viewer_napari/containers.py @@ -1,4 +1,5 @@ from magicgui.widgets import Container +from qtpy.QtGui import QFont from plantseg.viewer_napari.widgets import ( widget_add_custom_model, @@ -28,6 +29,7 @@ ) STYLE_SLIDER = "font-size: 9pt;" +MONOSPACE_FONT = QFont("Courier New", 9) # "Courier New" is a common monospaced font def get_data_io_tab(): @@ -59,6 +61,7 @@ def get_preprocessing_tab(): def get_segmentation_tab(): + widget_unet_prediction.model_id.native.setFont(MONOSPACE_FONT) container = Container( widgets=[ widget_unet_prediction, diff --git a/plantseg/viewer_napari/viewer.py b/plantseg/viewer_napari/viewer.py index 02241170..9704e083 100644 --- a/plantseg/viewer_napari/viewer.py +++ b/plantseg/viewer_napari/viewer.py @@ -25,7 +25,8 @@ def run_viewer(): (get_proofreading_tab(), 'Proofreading'), (get_extras_tab(), 'Models'), ]: - viewer.window.add_dock_widget(_containers, name=name, tabify=True) + this_widget = viewer.window.add_dock_widget(_containers, name=name, tabify=True) + this_widget.setFixedWidth(666) # Show data tab by default viewer.window._dock_widgets['Input/Output'].show()