diff --git a/album_catalog_index.db b/album_catalog_index.db index c54c844..58ad958 100644 Binary files a/album_catalog_index.db and b/album_catalog_index.db differ diff --git a/solutions/DL4MicEverywhere/embedseg-2d-zerocostdl4mic/CHANGELOG.md b/solutions/DL4MicEverywhere/embedseg-2d-zerocostdl4mic/CHANGELOG.md new file mode 100644 index 0000000..3d01579 --- /dev/null +++ b/solutions/DL4MicEverywhere/embedseg-2d-zerocostdl4mic/CHANGELOG.md @@ -0,0 +1,8 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.15.0] - 2024-10-15 +../CHANGELOG.md diff --git a/solutions/DL4MicEverywhere/embedseg-2d-zerocostdl4mic/solution.py b/solutions/DL4MicEverywhere/embedseg-2d-zerocostdl4mic/solution.py new file mode 100644 index 0000000..358a961 --- /dev/null +++ b/solutions/DL4MicEverywhere/embedseg-2d-zerocostdl4mic/solution.py @@ -0,0 +1,164 @@ +###album catalog: cellcanvas + +# Based on https://github.com/HenriquesLab/DL4MicEverywhere/blob/main/notebooks/ZeroCostDL4Mic_notebooks/Embedseg_DL4Mic/configuration.yaml +# and https://github.com/betaseg/solutions/blob/main/solutions/io.github.betaseg/cellsketch-plot/solution.py + +from album.runner.api import setup +import subprocess + +try: + subprocess.check_output('nvidia-smi') + gpu_access = True +except Exception: + gpu_access = False + +def install(): + from album.runner.api import get_app_path + from git import Repo + import subprocess + import requests + import shutil + import os + + # Clone the DL4MicEverywhere repository + clone_url = "https://github.com/HenriquesLab/DL4MicEverywhere" + repo_path = get_app_path().joinpath("DL4MicEverywhere") + Repo.clone_from(clone_url, repo_path) + assert (repo_path.exists()) + + # URL of the notebook you want to download + notebook_url = "https://raw.githubusercontent.com/HenriquesLab/ZeroCostDL4Mic/master/Colab_notebooks/EmbedSeg_2D_ZeroCostDL4Mic.ipynb" + + notebook_path = get_app_path().joinpath("EmbedSeg_2D_ZeroCostDL4Mic.ipynb") + notebook_path.parent.mkdir(parents=True, exist_ok=True) + + response = requests.get(notebook_url) + response.raise_for_status() + + with open(notebook_path, 'wb') as notebook_file: + notebook_file.write(response.content) + + assert notebook_path.exists(), "Notebook download failed" + + # Convert the notebook to its colabless form + section_to_remove = "1.0. 1.1. 2." + section_to_remove = section_to_remove.split(' ') + + python_command = ["python", ".tools/notebook_autoconversion/transform.py", "-p", f"{get_app_path()}", "-n", "EmbedSeg_2D_ZeroCostDL4Mic.ipynb", "-s"] + python_command += section_to_remove + + subprocess.run(python_command, cwd=to) + subprocess.run(["mv", get_app_path().joinpath("colabless_EmbedSeg_2D_ZeroCostDL4Mic.ipynb"), get_app_path().joinpath("EmbedSeg_2D_ZeroCostDL4Mic.ipynb")]) + + # Remove the cloned DL4MicEverywhere repository + if os.name == 'nt': + os.system(f'rmdir /s /q "{to}"') + else: + # rmtree has no permission to do this on Windows + shutil.rmtree(to) + +def run(): + from album.runner.api import get_args, get_app_path + import subprocess + import os + + # Fetch arguments and paths + args = get_args() + app_path = get_app_path() + + # Path to the downloaded notebook + notebook_path = app_path.joinpath("EmbedSeg_2D_ZeroCostDL4Mic.ipynb") + + # Ensure the notebook exists + assert notebook_path.exists(), "Notebook does not exist" + + # Output path for running the notebook + output_path = args.path + os.makedirs(output_path, exist_ok=True) + print(f"Saving output to {output_path}") + + # Set the LD_LIBRARY_PATH to allow TensorFlow to find the CUDA libraries + global gpu_access + if gpu_access: + os.environ["LD_LIBRARY_PATH"] = f"{os.environ['LD_LIBRARY_PATH']}:{os.environ['CONDA_PREFIX']}/lib" + + # Optionally, launch the Jupyter notebook to show the results + subprocess.run(["jupyter", "lab", str(notebook_path)], cwd=str(output_path)) + +if gpu_access: + channels = """ +- conda-forge +- nvidia +- anaconda +- defaults +""" + dependencies = """ +- python=3.9 +- cudatoolkit=11.7.1 +- cudnn=8.5.0 +- pip +- pkg-config +""" +else: + channels = """ +- conda-forge +- defaults +""" + dependencies = f""" +- python=3.9 +- pip +- pkg-config +""" + +env_file = f""" +channels: +{channels} +dependencies: +{dependencies} +- pip: + - GitPython==3.1.43 + - astropy==6.0.0 + - torch<=1.9.0 + - torchvision<=0.10.0 + - scikit-learn==1.3.2 + - embedseg==0.2.3 + - wget + - fpdf + - h5py + - tabulate + - matplotlib==3.5.0 + - scipy + - tifffile + - numba==0.56 + - tqdm + - jupyter + - pandas==1.3.0 + - seaborn + - scikit-image + - colorspacious + - pytest + - pycocotools +""" + +setup( + group="DL4MicEverywhere", + name="embedseg-2d-zerocostdl4mic", + version="1.15.0", + solution_creators=["DL4Mic team", "album team"], + title="embedseg-2d-zerocostdl4mic implementation.", + description="Instance segmentation of 2D images. EmbedSeg 2D is a deep-learning method that can be used to segment object from bioimages and was first published by Lalit et al. in 2021, on arXiv.", + documentation="https://raw.githubusercontent.com/HenriquesLab/ZeroCostDL4Mic/master/BioimageModelZoo/README.md", + tags=['colab', 'notebook', 'EmbedSeg', 'Segmentation', 'ZeroCostDL4Mic', 'dl4miceverywhere'], + args=[{ + "name": "path", + "type": "string", + "default": ".", + "description": "What is your working path?" + }], + cite=[{'doi': 'https://doi.org/10.1038/s41467-021-22518-0', 'text': 'von Chamier, L., Laine, R.F., Jukkala, J. et al. Democratising deep learning for microscopy with ZeroCostDL4Mic. Nat Commun 12, 2276 (2021). https://doi.org/10.1038/s41467-021-22518-0'}, {'text': 'Manan Lalit, Pavel Tomancak, Florian Jug. Embedding-based Instance Segmentation in Microscopy. arXiv:2101.10033.', 'url': 'https://arxiv.org/abs/2101.10033'}], + album_api_version="0.5.1", + covers=[], + run=run, + install=install, + dependencies={"environment_file": env_file}, +) diff --git a/solutions/DL4MicEverywhere/embedseg-2d-zerocostdl4mic/solution.yml b/solutions/DL4MicEverywhere/embedseg-2d-zerocostdl4mic/solution.yml new file mode 100644 index 0000000..9af0087 --- /dev/null +++ b/solutions/DL4MicEverywhere/embedseg-2d-zerocostdl4mic/solution.yml @@ -0,0 +1,34 @@ +album_api_version: 0.5.1 +args: +- default: . + description: What is your working path? + name: path + type: string +changelog: ../CHANGELOG.md +cite: +- doi: https://doi.org/10.1038/s41467-021-22518-0 + text: von Chamier, L., Laine, R.F., Jukkala, J. et al. Democratising deep learning + for microscopy with ZeroCostDL4Mic. Nat Commun 12, 2276 (2021). https://doi.org/10.1038/s41467-021-22518-0 +- text: Manan Lalit, Pavel Tomancak, Florian Jug. Embedding-based Instance Segmentation + in Microscopy. arXiv:2101.10033. + url: https://arxiv.org/abs/2101.10033 +covers: [] +description: Instance segmentation of 2D images. EmbedSeg 2D is a deep-learning method + that can be used to segment object from bioimages and was first published by Lalit + et al. in 2021, on arXiv. +documentation: https://raw.githubusercontent.com/HenriquesLab/ZeroCostDL4Mic/master/BioimageModelZoo/README.md +group: DL4MicEverywhere +name: embedseg-2d-zerocostdl4mic +solution_creators: +- DL4Mic team +- album team +tags: +- colab +- notebook +- EmbedSeg +- Segmentation +- ZeroCostDL4Mic +- dl4miceverywhere +timestamp: '2024-10-15T17:48:35.346227' +title: embedseg-2d-zerocostdl4mic implementation. +version: 1.15.0