From d233880230f543d37c78a52ae106362681073fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Hidalgo?= Date: Tue, 15 Oct 2024 17:51:33 +0100 Subject: [PATCH] Adding new/updated DL4MicEverywhere_yolov2-zerocostdl4mic_1.13 --- album_catalog_index.db | Bin 102400 -> 102400 bytes .../yolov2-zerocostdl4mic/CHANGELOG.md | 8 + .../yolov2-zerocostdl4mic/solution.py | 181 ++++++++++++++++++ .../yolov2-zerocostdl4mic/solution.yml | 34 ++++ 4 files changed, 223 insertions(+) create mode 100644 solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/CHANGELOG.md create mode 100644 solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/solution.py create mode 100644 solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/solution.yml diff --git a/album_catalog_index.db b/album_catalog_index.db index 8f4bc0bc80021d401af9eada75888d36bcaa8c6d..594d82930bab31662abb350a07eea7741496bee3 100644 GIT binary patch delta 970 zcmXxj&rj2E6aeskxACfVYde2L2{Cl2h`N<;OS`%$DnCY4FeCT_@K@Z{3X5ZdF(v9j z#_4OkXm;qqgCy#O#6+D+yr>7y2G1t=50Dry#>AM|J+Mjp{q*&{m)BqOi!i?k4_iWW z9LF_#J8q9UEHd}%+Ot-FNAPKlSJJ-V(|TAQ3~rU90j{}uJUx`YrB7vwH#3F$+vrek zn^zW))*8iIr9aY7X-)c757Tc_?Z*>A+@*MNc}vJUz7g8${Nfc76w<Zpg!k^1P;iza_uEY$dy`G8mv3tqF| zAqjdn@_N?O?tZvW{7KQQ@ti4oh z;+rDtO$NWer9$H_i1?fnpL-V{i@}Alh|I;T(H%VtPHpDr&X(JyLg|(syW^BgxzcRK zE*Mk!+LRHwr|QM;v>q zR8-oPflPTaW9Qw!S#niL95$V};n3?ep3PdCW@c?Y?j-D7j#@S~%y$Y2$bOluxjZGU zKCOwm?))c@V1N@IWor8KGZI+co3j(V47aXnipmx>dO zh)y+2Ih9JK+;oEUMy;qaJ*_HnQ?p`mQ#YfEUCJjFjjEbP6PKjYQpp76`dGo{7V8X^TXsk@#b9GbPrhL%}J3SU?&hMV8;<7z>Xmbz`7AOu%n1x zU`G&VfF%(IumqwX*kME;Fbi=JSR63~%tXupGY}`?9_vC)0n-shU>c$Xj3RQtIuQ;q z6_EuNL)--B{U_e^d0>YS6Tl84RA2`XbHF+f8DRSnWnk@yPOoYoDhX^aViwpQ#5Axr SLu}%bgF%*T6ry9n;hR delta 221 zcmZozz}B#UZGtp!C<6n7BoGS$G2=uHbH>n(2}|Ue)p@o~W>@gvEGQ7qvw5qIPqHxo zHwI?@H$YVk68yjUKk~off3sQ8;5Pr{_w%{<0>gB4>FwyPn(6$SlS0J(>N2DNux;f3x@f ztp=NgJ_IvvRuEXrH|Yb*aux+f0cL)t3)9&R80CSARxxeAV8m$R%iPJWznwjRQ5a;O MDA#uVZpMo&00SIAY5)KL diff --git a/solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/CHANGELOG.md b/solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/CHANGELOG.md new file mode 100644 index 0000000..a59c374 --- /dev/null +++ b/solutions/DL4MicEverywhere/yolov2-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.13] - 2024-10-15 +../CHANGELOG.md diff --git a/solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/solution.py b/solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/solution.py new file mode 100644 index 0000000..40edbfb --- /dev/null +++ b/solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/solution.py @@ -0,0 +1,181 @@ +###album catalog: cellcanvas + +# Based on https://github.com/HenriquesLab/DL4MicEverywhere/blob/main/notebooks/ZeroCostDL4Mic_notebooks/YOLOv2_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/YOLOv2_ZeroCostDL4Mic.ipynb" + + notebook_path = get_app_path().joinpath("YOLOv2_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.1. 1.2. 2. 6.3." + section_to_remove = section_to_remove.split(' ') + + python_command = ["python", ".tools/notebook_autoconversion/transform.py", "-p", f"{get_app_path()}", "-n", "YOLOv2_ZeroCostDL4Mic.ipynb", "-s"] + python_command += section_to_remove + + subprocess.run(python_command, cwd=to) + subprocess.run(["mv", get_app_path().joinpath("colabless_YOLOv2_ZeroCostDL4Mic.ipynb"), get_app_path().joinpath("YOLOv2_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("YOLOv2_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.7 +- cudatoolkit=11.8.0 +- cudnn=8.6.0 +- pip +- pkg-config +""" +else: + channels = """ +- conda-forge +- defaults +""" + dependencies = f""" +- python=3.7 +- pip +- pkg-config +""" + +env_file = f""" +channels: +{channels} +dependencies: +{dependencies} +- pip: + - GitPython==3.1.43 + - dask==2.12.0 + - fpdf==1.7.2 + - gast==0.2.2 + - google==2.0.3 + - h5py==2.10.0 + - httplib2==0.17.4 + - image==1.5.33 + - imageio==2.4.1 + - imgaug==0.2.9 + - joblib==1.0.1 + - keras==2.3.1 + - multiprocess==0.70.11.1 + - numpy==1.19.5 + - oauth2client==4.1.3 + - opencv-python==3.4.14.53 + - pandas==1.2.3 + - pascal-voc-writer==0.1.4 + - portpicker==1.3.1 + - prettytable==2.0.0 + - protobuf==3.20.* + - PyMuPDF==1.18.16 + - psutil==5.4.8 + - py==1.10.0 + - pyasn1==0.4.8 + - pydot==1.3.0 + - rsa==4.7.2 + - scikit-image==0.18.0 + - scikit-learn==0.22.2.post1 + - scipy==1.4.1 + - six==1.15.0 + - tblib==1.7.0 + - tensorboard==1.15.0 + - tensorflow==1.15.2 + - termcolor==1.1.0 + - toolz==0.11.1 + - tqdm==4.41.1 + - uritemplate==3.0.1 + - wrapt==1.12.1 +""" + +setup( + group="DL4MicEverywhere", + name="yolov2-zerocostdl4mic", + version="1.13", + solution_creators=["DL4Mic team", "album team"], + title="yolov2-zerocostdl4mic implementation.", + description="Object detection of 2D images. YOLOv2 is an object detection network developed by Redmon & Farhadi, which identifies objects in images and draws bounding boxes around them.", + documentation="https://raw.githubusercontent.com/HenriquesLab/ZeroCostDL4Mic/master/BioimageModelZoo/README.md", + tags=['colab', 'notebook', 'YOLOv2', 'object detection', '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'}, {'doi': 'https://doi.org/10.1109/CVPR.2017.690', 'text': 'J. Redmon and A. Farhadi, YOLO9000: Better, Faster, Stronger, 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017, pp. 6517-6525, doi: 10.1109/CVPR.2017.690.'}], + album_api_version="0.5.1", + covers=[], + run=run, + install=install, + dependencies={"environment_file": env_file}, +) diff --git a/solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/solution.yml b/solutions/DL4MicEverywhere/yolov2-zerocostdl4mic/solution.yml new file mode 100644 index 0000000..4341a75 --- /dev/null +++ b/solutions/DL4MicEverywhere/yolov2-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 +- doi: https://doi.org/10.1109/CVPR.2017.690 + text: 'J. Redmon and A. Farhadi, YOLO9000: Better, Faster, Stronger, 2017 IEEE Conference + on Computer Vision and Pattern Recognition (CVPR), 2017, pp. 6517-6525, doi: 10.1109/CVPR.2017.690.' +covers: [] +description: Object detection of 2D images. YOLOv2 is an object detection network + developed by Redmon & Farhadi, which identifies objects in images and draws bounding + boxes around them. +documentation: https://raw.githubusercontent.com/HenriquesLab/ZeroCostDL4Mic/master/BioimageModelZoo/README.md +group: DL4MicEverywhere +name: yolov2-zerocostdl4mic +solution_creators: +- DL4Mic team +- album team +tags: +- colab +- notebook +- YOLOv2 +- object detection +- ZeroCostDL4Mic +- dl4miceverywhere +timestamp: '2024-10-15T17:51:32.154590' +title: yolov2-zerocostdl4mic implementation. +version: '1.13'