diff --git a/qim3d/gui/annotation_tool.py b/qim3d/gui/annotation_tool.py index e36d14fc64d2c80e9698251ddf2f7976a792ca0a..c35d089b2c8fef68e6ab563ed9939c7e50314e40 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 d0de17fc51e214a349ff8a25fb95cd67a7bf5eaf..35b6083557d5c53ced3276d986b5909ac842b184 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 d619d3254985bb87b7b375d2869100349815bfe7..811af41edd12b15d5639d824e4630c49117c6be1 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 c9b7cdb3fd1d9286b60222dd0fe801ce0df42c02..a4c9b22be35360b61fdae32830b9b6d4cebe93f3 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):