This file contains 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 | |
from collections import defaultdict | |
def process_tensorboard_events_file(tensorboard_events_filename, tf_version=2, tags=None): | |
assert isinstance(tags, list) | |
for v in tags: | |
assert isinstance(v, str) | |
it = _get_events_iterator(tensorboard_events_filename, tf_version) | |
ans = defaultdict(list) | |
for event in it: |
This file contains 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/python | |
import SimpleITK as sitk | |
import vtk | |
import numpy as np | |
from vtk.util.vtkConstants import * | |
def numpy2VTK(img,spacing=[1.0,1.0,1.0]): | |
# evolved from code from Stou S., |
This file contains 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 abc | |
import six | |
@six.add_metaclass(abc.ABCMeta) | |
class Platform(object): | |
"""Base class for all OpenGL platforms. | |
Parameters |
This file contains 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 cv2 | |
import numpy as np | |
def base_tens_stats(tens): | |
print(f'shape={tens.shape} min={tens.min()} mean={tens.mean()} max={tens.max()}') | |
x = np.random.randint(0,1020, (256,256,20)).astype(np.uint16) | |
base_tens_stats(x) |
This file contains 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
def make_parallel(fn, num_gpus, inputs_to_be_splitted, inputs_to_be_passed_as_is=None): | |
''' | |
Converts a function into a parallel version of it, using a simple syncronized data parallelsim | |
:param fn: a tensorflow function | |
:param num_gpus: number of gpus | |
:param inputs_to_be_splitted: a dict with all of the tensorflow variables/placeholders that will be split before being passed to fn | |
:param inputs_to_be_passed_as_is: a dict with all of the variables that will be passed as is to fn | |
:return: | |
''' |
This file contains 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
from PyQt4.QtGui import * | |
from PyQt4.QtCore import * | |
import networkx as nx | |
from networkx.drawing.nx_agraph import graphviz_layout | |
class ZedNode(QGraphicsEllipseItem): | |
rad = 5 | |
def __init__(self, key): |
This file contains 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
from keras import backend as K | |
import keras.optimizers | |
from keras.layers import Convolution2D, MaxPooling2D | |
from keras.layers import Activation, Dropout, Flatten, Dense, Input | |
from keras.models import Model | |
import numpy as np | |
def make_model(input_dim_size): | |
if K.image_dim_ordering() == 'tf': | |
input_shape = (input_dim_size, input_dim_size,1) |