From 851d5719041a40d7f63253f95153a6ba2b202cf2 Mon Sep 17 00:00:00 2001 From: Felipe <fima@dtu.dk> Date: Mon, 15 Jul 2024 15:23:46 +0200 Subject: [PATCH] Hotfix: no relative import for interface --- qim3d/gui/annotation_tool.py | 61 +++++++++++++++++------------------- qim3d/gui/data_explorer.py | 2 +- qim3d/gui/iso3d.py | 2 +- qim3d/gui/local_thickness.py | 2 +- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/qim3d/gui/annotation_tool.py b/qim3d/gui/annotation_tool.py index e36d14fc..c35d089b 100644 --- a/qim3d/gui/annotation_tool.py +++ b/qim3d/gui/annotation_tool.py @@ -30,22 +30,20 @@ from PIL import Image from qim3d.io import load, save from qim3d.utils import overlay_rgb_images -from .interface import BaseInterface +from qim3d.gui.interface import BaseInterface -#TODO: img in launch should be self.img +# TODO: img in launch should be self.img -class Interface(BaseInterface): - def __init__(self, - name_suffix:str = "", - verbose: bool = False, - img = None): - super().__init__(title = "Annotation Tool", - height = 768, - width = "100%", - verbose = verbose, - custom_css="annotation_tool.css" - ) +class Interface(BaseInterface): + def __init__(self, name_suffix: str = "", verbose: bool = False, img=None): + super().__init__( + title="Annotation Tool", + height=768, + width="100%", + verbose=verbose, + custom_css="annotation_tool.css", + ) self.username = getpass.getuser() self.temp_dir = os.path.join(tempfile.gettempdir(), f"qim-{self.username}") @@ -56,7 +54,7 @@ class Interface(BaseInterface): self.img_editor = None self.masks_rgb = None self.temp_files = [] - + def get_result(self): # Get the temporary files from gradio temp_path_list = [] @@ -73,7 +71,7 @@ class Interface(BaseInterface): masks[mask_name] = load(temp_file) return masks - + def clear_files(self): """ Should be moved up to __init__ function, but given how is this interface implemented in some files @@ -128,19 +126,21 @@ class Interface(BaseInterface): self.temp_files.append(filepath) return files_list - + def define_interface(self, **kwargs): brush = gr.Brush( - colors=[ - "rgb(255,50,100)", - "rgb(50,250,100)", - "rgb(50,100,255)", - ], - color_mode="fixed", - default_size=10, - ) + colors=[ + "rgb(255,50,100)", + "rgb(50,250,100)", + "rgb(50,100,255)", + ], + color_mode="fixed", + default_size=10, + ) with gr.Row(): - with gr.Column(scale=6, ): + with gr.Column( + scale=6, + ): img_editor = gr.ImageEditor( value=( { @@ -166,12 +166,12 @@ class Interface(BaseInterface): with gr.Row(): overlay_img = gr.Image( - show_download_button=False, show_label=False, visible=False, + show_download_button=False, + show_label=False, + visible=False, ) with gr.Row(): - masks_download = gr.File( - label="Download masks", visible=False - ) + masks_download = gr.File(label="Download masks", visible=False) # fmt: off img_editor.change( @@ -180,6 +180,3 @@ class Interface(BaseInterface): fn = self.set_visible, inputs = None, outputs = overlay_img).then( # Makes the preview visible fn = self.cerate_download_list, inputs = img_editor, outputs = masks_download).then(# Separates the color mask and put them into file list fn = self.set_visible, inputs = None, outputs = masks_download) # Displays the download file list - - - diff --git a/qim3d/gui/data_explorer.py b/qim3d/gui/data_explorer.py index d0de17fc..35b60835 100644 --- a/qim3d/gui/data_explorer.py +++ b/qim3d/gui/data_explorer.py @@ -28,7 +28,7 @@ from qim3d.io import load from qim3d.io.logger import log from qim3d.utils import internal_tools -from .interface import BaseInterface +from qim3d.gui.interface import BaseInterface class Interface(BaseInterface): diff --git a/qim3d/gui/iso3d.py b/qim3d/gui/iso3d.py index d619d325..811af41e 100644 --- a/qim3d/gui/iso3d.py +++ b/qim3d/gui/iso3d.py @@ -25,7 +25,7 @@ from scipy import ndimage from qim3d.io import load from qim3d.io.logger import log -from .interface import InterfaceWithExamples +from qim3d.gui.interface import InterfaceWithExamples #TODO img in launch should be self.img diff --git a/qim3d/gui/local_thickness.py b/qim3d/gui/local_thickness.py index c9b7cdb3..a4c9b22b 100644 --- a/qim3d/gui/local_thickness.py +++ b/qim3d/gui/local_thickness.py @@ -42,7 +42,7 @@ import tifffile import localthickness as lt from qim3d.io import load -from .interface import InterfaceWithExamples +from qim3d.gui.interface import InterfaceWithExamples class Interface(InterfaceWithExamples): -- GitLab