This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from csbdeep.utils import normalize | |
def norm_minmse(gt, x, normalize_gt=True): | |
""" | |
normalizes and affinely scales an image pair such that the MSE is minimized | |
Parameters | |
---------- | |
gt: ndarray |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from colorsys import rgb_to_hls, hls_to_rgb | |
def _rgb2hls(im): | |
return np.stack(np.vectorize(rgb_to_hls)(*im.transpose(2,0,1)/256), axis=-1) | |
def _hls2rgb(im): | |
return (255*np.stack(np.vectorize(hls_to_rgb)(*im.transpose(2,0,1)), axis=-1)).astype(np.uint8) | |
def invert(img): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
source ~/.bashrc | |
git clone https://github.com/mpicbg-csbd/stardist | |
my_venvs_create stardist_env | |
my_venvs_activate stardist_env | |
pip install tifffile==2019.7.2 # as newer versions somehow wont install on noto | |
pip install stardist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@ ImagePlus imp | |
#@ OUTPUT ImagePlus result | |
from ij import IJ | |
from ij.plugin.frame import RoiManager | |
result = IJ.createImage("Labeling", "16-bit black", imp.getWidth(), imp.getHeight(), 1) | |
ip = result.getProcessor() | |
rm = RoiManager.getInstance() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.ndimage import label, zoom | |
from stardist.matching import matching | |
from stardist.plot import render_label, render_label_pred | |
np.random.seed(42) | |
def create_example(): | |
rand_gt = np.random.uniform(0,1,(8,8)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* QuPath-Script to export annotations to label tif images (e.g. to be used for stardist) | |
Use "Run for project" to export annotations for all images within a QuPath project | |
Afterwards both images and mask tiffs will be stored in the project subfolder | |
ground_truth | |
├── images | |
└── masks | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
import psutil | |
import os | |
from stardist.models import Config3D, StarDist3D | |
os.environ['CUDA_VISIBLE_DEVICES']= "0"# '1,0' | |
from tensorflow.keras.utils import Sequence | |
import stardist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Average-Downsampling example in OpenCL (via gputools) | |
# please install it first via | |
# pip install gputools | |
import numpy as np | |
from gputools import OCLProgram, OCLArray, get_device | |
from timeit import default_timer | |
from skimage.transform import downscale_local_mean | |
# opencl kernel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The default momentum of MobileNet (for running average calculation) in tf seems to be very high (0.99?), resulting in huge (and suprising) differences in train vs evaluate loss | |
https://github.com/keras-team/keras/issues/6977 | |
Setting it to something sensible (e.g. 0.9) fixes this | |
https://stackoverflow.com/questions/65415799/fit-works-as-expected-but-then-during-evaluate-model-performs-at-chance/66692755#66692755 | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: dl-image-mw | |
channels: | |
- defaults | |
- nvidia | |
dependencies: | |
- python=3.9 | |
- cudatoolkit=11.0.* | |
- cudnn=8.0.* | |
- jupyter | |
- numpy |
OlderNewer