Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
7936d6f
Initial commit
Romain-Laine Feb 17, 2021
8595503
Notebook upload
Romain-Laine Feb 17, 2021
dc76037
Update requirements.txt
Romain-Laine Feb 17, 2021
29919b6
Update requirements.txt
Romain-Laine Feb 17, 2021
5e71d97
Update requirements.txt
Romain-Laine Feb 17, 2021
9f30172
Update requirements.txt
Romain-Laine Feb 17, 2021
f448ad3
Update requirements.txt
Romain-Laine Feb 17, 2021
68af116
Update requirements.txt
Romain-Laine Feb 17, 2021
782162b
Update requirements.txt
Romain-Laine Feb 17, 2021
d27163a
Update requirements.txt
Romain-Laine Feb 17, 2021
db50af3
Update requirements.txt
Romain-Laine Feb 17, 2021
778f0ce
Update requirements.txt
Romain-Laine Feb 17, 2021
a505bf5
Update requirements.txt
Romain-Laine Feb 17, 2021
6041af6
Update requirements.txt
Romain-Laine Feb 17, 2021
fe24595
Update requirements.txt
Romain-Laine Feb 17, 2021
4c64c3e
Update requirements.txt
Romain-Laine Feb 17, 2021
03c7031
Update requirements.txt
Romain-Laine Feb 17, 2021
1d36bb2
Update requirements.txt
Romain-Laine Feb 17, 2021
b775e8e
Adding training dataset
Romain-Laine Feb 17, 2021
889f389
requirements.txt update
Romain-Laine Feb 17, 2021
72401c8
Create Dockerfile
Romain-Laine Feb 18, 2021
9c05d13
Update Dockerfile
ctr26 Feb 21, 2021
1aa3c1f
dockerfile (tf latest)
ctr26 Feb 24, 2021
810b030
minimal jupyter with cuda merged
ctr26 Feb 24, 2021
b52e8ee
cuda 10.2
ctr26 Feb 24, 2021
82f833c
Chown is being funny
ctr26 Feb 24, 2021
02b6ae8
buster?
ctr26 Feb 24, 2021
e7b3cb7
check pip installs were correct though
ctr26 Feb 24, 2021
6f9d81e
remove tf 1.15
ctr26 Feb 24, 2021
e4cc934
Merge pull request #1 from ctr26/tf
ctr26 Feb 24, 2021
28ba260
Update Dockerfile
ctr26 Feb 24, 2021
8187a44
try 1.15 again?
ctr26 Feb 24, 2021
e119cc5
N2V example
ctr26 Feb 24, 2021
bbedfa4
Update Dockerfile
ctr26 Feb 24, 2021
1bbd388
update minimal
ctr26 Feb 24, 2021
faef636
Merge branch 'tf-1.15' of https://github.com/ctr26/ZCDL4_binder into …
ctr26 Feb 24, 2021
c1910f8
Merge branch 'main' into tf-1.15
ctr26 Feb 24, 2021
0bcee8d
Merge pull request #2 from ctr26/tf-1.15
ctr26 Feb 24, 2021
85e17ec
Code is all in place, now to plumb
ctr26 May 12, 2021
704e981
Added pre-report
ctr26 May 13, 2021
b5e5a8d
Added setup complete
ctr26 May 13, 2021
74dc7a6
pytest warnings supressed
ctr26 May 13, 2021
3153dca
Attempt at quality checks
ctr26 May 14, 2021
2b08422
Added predict and quality (ish)
ctr26 May 14, 2021
4d2fe7e
Missing import
ctr26 May 14, 2021
407a5fe
assess conditions
ctr26 May 14, 2021
765dbe6
default_params_test
ctr26 May 14, 2021
315dfa0
Added a run function to model(s)
ctr26 May 17, 2021
ee82dc6
Moved models to a submodule
ctr26 May 17, 2021
c4f9c50
Attempt at making models a submod
ctr26 May 17, 2021
936cc2e
Update project
ctr26 May 17, 2021
65e0640
Adding CARE
ctr26 May 18, 2021
3f9554e
Attempted to remove config dict dependence
ctr26 May 18, 2021
72077fb
Model structure
ctr26 May 20, 2021
11417bd
bugs in reporting
ctr26 May 20, 2021
eb7a7c9
bugs in assess
ctr26 May 20, 2021
fdb2f47
bugs in quality
ctr26 May 20, 2021
12ff9b5
Passing CARE tests, more tests needed
ctr26 May 20, 2021
e88d7bd
n2v passing
ctr26 May 21, 2021
a06bcee
Sorting out defaults for N2V
ctr26 May 21, 2021
9d1d562
House keeping
ctr26 Jun 9, 2021
8b6ad76
Bug fixes
ctr26 Jun 11, 2021
2f094de
Removing large files
ctr26 Jun 11, 2021
fb85a89
fixing import of h5py
ctr26 Jun 11, 2021
e3946c8
torch test
ctr26 Aug 9, 2021
b2f1f1b
move dockerfile
ctr26 Aug 9, 2021
bd1ce59
torch working locally
ctr26 Aug 9, 2021
404fa0c
merge
ctr26 Jun 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.pythonPath": "/home/ctr26/miniconda3/envs/dl4mic/bin/python",
"python.formatting.provider": "black",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true
}

1,984 changes: 1,984 additions & 0 deletions ColabNotebooks/CARE_2D_ZeroCostDL4Mic.ipynb

Large diffs are not rendered by default.

528 changes: 528 additions & 0 deletions ColabNotebooks/N2V.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ColabNotebooks/Noise2Void_2D_ZeroCostDL4Mic copy.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ColabNotebooks/Noise2Void_2D_ZeroCostDL4Mic.ipynb

Large diffs are not rendered by default.

121 changes: 121 additions & 0 deletions ColabNotebooks/minimal.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10-final"
},
"orig_nbformat": 2,
"kernelspec": {
"name": "python3",
"display_name": "Python 3.7.10 64-bit ('tf': conda)",
"metadata": {
"interpreter": {
"hash": "01a8c3e581587ef845b14c27476cc2daada005a8e900d0cc550301b789c363ba"
}
}
}
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#@markdown ##Run this cell to check if you have GPU access\n",
"# %tensorflow_version 1.x\n",
"\n",
"import tensorflow as tf\n",
"if tf.test.gpu_device_name()=='':\n",
" print('You do not have GPU access.') \n",
" print('Did you change your runtime ?') \n",
" print('If the runtime setting is correct then Google did not allocate a GPU for your session')\n",
" print('Expect slow performance. To access GPU try reconnecting later')\n",
"\n",
"else:\n",
" print('You have GPU access')\n",
" !nvidia-smi"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Notebook_version = ['1.12']\n",
"import tensorflow\n",
"# ------- Variable specific to N2V -------\n",
"from n2v.models import N2VConfig, N2V\n",
"from csbdeep.utils import plot_history\n",
"from n2v.utils.n2v_utils import manipulate_val_data\n",
"from n2v.internals.N2V_DataGenerator import N2V_DataGenerator\n",
"from csbdeep.io import save_tiff_imagej_compatible\n",
"\n",
"# ------- Common variable to all ZeroCostDL4Mic notebooks -------\n",
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"import urllib\n",
"import os, random\n",
"import shutil \n",
"import zipfile\n",
"from tifffile import imread, imsave\n",
"import time\n",
"import sys\n",
"import wget\n",
"from pathlib import Path\n",
"import pandas as pd\n",
"import csv\n",
"from glob import glob\n",
"from scipy import signal\n",
"from scipy import ndimage\n",
"from skimage import io\n",
"from sklearn.linear_model import LinearRegression\n",
"from skimage.util import img_as_uint\n",
"import matplotlib as mpl\n",
"from skimage.metrics import structural_similarity\n",
"from skimage.metrics import peak_signal_noise_ratio as psnr\n",
"from astropy.visualization import simple_norm\n",
"from skimage import img_as_float32\n",
"from fpdf import FPDF, HTMLMixin\n",
"from datetime import datetime\n",
"from pip._internal.operations.freeze import freeze\n",
"import subprocess\n",
"from datetime import datetime\n",
"\n",
"# Colors for the warning messages\n",
"class bcolors:\n",
" WARNING = '\\033[31m'\n",
"W = '\\033[0m' # white (normal)\n",
"R = '\\033[31m' # red\n",
"\n",
"#Disable some of the tensorflow warnings\n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\")\n",
"\n",
"print(\"Libraries installed\")\n",
"\n",
"\n",
"# Check if this is the latest version of the notebook\n",
"Latest_notebook_version = pd.read_csv(\"https://raw.githubusercontent.com/HenriquesLab/ZeroCostDL4Mic/master/Colab_notebooks/Latest_ZeroCostDL4Mic_Release.csv\")\n",
"print('Notebook version: '+Notebook_version[0])\n",
"strlist = Notebook_version[0].split('.')\n",
"Notebook_version_main = strlist[0]+'.'+strlist[1]\n",
"if Notebook_version_main == Latest_notebook_version.columns:\n",
" print(\"This notebook is up-to-date.\")\n",
"else:\n",
" print(bcolors.WARNING +\"A new version of this notebook has been released. We recommend that you download it at https://github.com/HenriquesLab/ZeroCostDL4Mic/wiki\")\n"
]
}
]
}
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2020 Quantitative Imaging and Nanobiophysics Group
=======

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,34 @@ DOI: [https://doi.org/10.1038/s41467-021-22518-0](https://www.nature.com/article
[8]: https://github.com/HenriquesLab/ZeroCostDL4Mic/blob/master/Wiki_files/VideoDemoScreenshot1.png
[wikiPage]: https://github.com/HenriquesLab/DeepLearning_Collab/wiki
[wikiPageContributors]: https://github.com/HenriquesLab/ZeroCostDL4Mic/wiki#contributors

=======

# dl4mic

Packaged form of [ZeroCostDl4Mic](https://github.com/HenriquesLab/ZeroCostDL4Mic) to make the process more platform agnostic.
Attempts to bundle reusable code and structure model training and prediction into a no-code config file toolset.


pip install git+https://github.com/ctr26/dl4mic


Currently working with Noise2Void and Care2D

## Build and test

This project uses poetry to build, test and manage dependnecies:

Quick start:
peotry build
poetry install
poetry run pytest

Note that testing is (rightly) slow due to running model epochs for testing

## Todo:

- Find all the bugs
- Implement the full roster of ZeroCostDL4Mic models.
- Command line interface
- Implement lazy loading of large/uninstalled packages (looking at you pyTorch)
26 changes: 26 additions & 0 deletions _Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM tensorflow/tensorflow:1.15.5-gpu-jupyter

# --- Jupyter

# install the notebook package
RUN pip install --no-cache --upgrade pip && \
pip install --no-cache notebook

# create user with a home directory
ARG NB_USER
ARG NB_UID
ENV USER ${NB_USER}
ENV HOME /home/${NB_USER}

RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}
WORKDIR ${HOME}
USER ${USER}

# RUN conda install pip --yes

COPY . .

RUN pip install --no-cache-dir -r requirements.txt
53 changes: 53 additions & 0 deletions dl4mic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# import tensorflow as tf
# ------- Common variable to all ZeroCostDL4Mic notebooks -------

import numpy as np
from matplotlib import pyplot as plt
import urllib
import os, random
import shutil
import zipfile
from tifffile import imread, imsave
import time
import sys
import wget
from pathlib import Path
import pandas as pd
import csv
from glob import glob
from scipy import signal
from scipy import ndimage
from skimage import io
from sklearn.linear_model import LinearRegression
from skimage.util import img_as_uint
import matplotlib as mpl
from skimage.metrics import structural_similarity
from skimage.metrics import peak_signal_noise_ratio as psnr
from astropy.visualization import simple_norm
from skimage import img_as_float32
from fpdf import FPDF, HTMLMixin
from datetime import datetime
from pip._internal.operations.freeze import freeze
import subprocess
from datetime import datetime

class bcolors:
WARNING = "\033[31m"


W = "\033[0m" # white (normal)
R = "\033[31m" # red

ref_1 = 'References:\n - ZeroCostDL4Mic: von Chamier, Lucas & Laine, Romain, et al. "ZeroCostDL4Mic: an open platform to simplify access and use of Deep-Learning in Microscopy." BioRxiv (2020).'


from . import models


# def __main__():
# read_latest_notebook_version()





52 changes: 52 additions & 0 deletions dl4mic/assess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import matplotlib as plt
from tifffile.tifffile import imread
from . import models
import random
import os


def full(Data_folder, Result_folder, Data_type):
if not ((Data_folder is None) or (Result_folder is None) or (Data_type is None)):
display_random_image(Data_folder, Result_folder, Data_type)
pass


def display_random_image(Data_folder, Result_folder, Data_type):
try:
# if Data_folder is not None:
file_list = os.listdir(Data_folder)
random_choice = random.choice(file_list)
x = imread(os.path.join(Data_folder,random_choice))

os.chdir(Result_folder)
y = imread(os.path.join(Result_folder,random_choice))

if Data_type == models.params.Data_type.SINGLE_IMAGES:

f = plt.figure(figsize=(16, 8))
plt.subplot(1, 2, 1)
plt.imshow(x, interpolation="nearest")
plt.title("Input")
plt.axis("off")
plt.subplot(1, 2, 2)
plt.imshow(y, interpolation="nearest")
plt.title("Predicted output")
plt.axis("off")
plt.show()

if Data_type == models.params.Data_type.STACKS:

f = plt.figure(figsize=(16, 8))
plt.subplot(1, 2, 1)
plt.imshow(x[1], interpolation="nearest")
plt.title("Input")
plt.axis("off")
plt.subplot(1, 2, 2)
plt.imshow(y[1], interpolation="nearest")
plt.title("Predicted output")
plt.axis("off")
plt.show()
except FileExistsError:
print("Couldn't find a random image")
except IndexError:
print("Couldn't find a random image")
Loading