How to use the batchflow.models.tf.TFModel function in batchflow

To help you get started, we’ve selected a few batchflow examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github analysiscenter / batchflow / batchflow / models / tf / unet.py View on Github external
"""  Ronneberger O. et al "`U-Net: Convolutional Networks for Biomedical Image Segmentation
`_"
"""
import tensorflow as tf
import numpy as np

from .layers import conv_block
from . import TFModel

class UNet(TFModel):
    """ UNet

    **Configuration**

    inputs : dict
        dict with 'images' and 'masks' (see :meth:`~.TFModel._make_inputs`)

    body : dict
        num_blocks : int
            number of downsampling/upsampling blocks (default=4)

        filters : list of int
            number of filters in each block (default=[128, 256, 512, 1024])

        downsample : dict
            parameters for downsampling block
github analysiscenter / batchflow / batchflow / models / tf / vnet.py View on Github external
"""  Milletari F. et al "`V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation
`_"
"""
import tensorflow as tf
import numpy as np

from ... import is_best_practice
from .layers import conv_block
from . import TFModel
from .resnet import ResNet


class VNet(TFModel):
    """ VNet

    **Configuration**

    inputs : dict
        dict with 'images' and 'masks' (see :meth:`~.TFModel._make_inputs`)

    body : dict
        num_blocks : int
            number of downsampling blocks (default=5)

        filters : list of int
            number of filters in each block (default=[16, 32, 64, 128, 256])

    head : dict
        num_classes : int
github analysiscenter / batchflow / batchflow / models / tf / mobilenet.py View on Github external
def default_config(cls):
        config = TFModel.default_config()
        config['initial_block'] = dict(layout='cna', filters=32, kernel_size=3, strides=2)
        config['body'].update(_V1_DEFAULT_BODY)
        config['head'].update(dict(layout='Vf'))
        config['loss'] = 'ce'
        return config
github analysiscenter / batchflow / batchflow / models / tf / fcn.py View on Github external
"""
Shelhamer E. et al "`Fully Convolutional Networks for Semantic Segmentation
`_"
"""
import tensorflow as tf

from . import TFModel, VGG16
from .layers import conv_block


class FCN(TFModel):
    """ Base Fully convolutional network (FCN) """
    @classmethod
    def default_config(cls):
        config = TFModel.default_config()
        config['common/dropout_rate'] = .5
        config['initial_block/base_network'] = VGG16
        config['body/filters'] = 100
        config['body/upsample'] = dict(layout='t', kernel_size=4)
        config['head/upsample'] = dict(layout='t')

        config['loss'] = 'ce'
        config['optimizer'] = ('Momentum', dict(learning_rate=1e-4, momentum=.9))

        return config

    def build_config(self, names=None):
github analysiscenter / batchflow / batchflow / models / tf / vgg.py View on Github external
def default_config(cls):
        config = TFModel.default_config()
        config['common/conv/use_bias'] = False
        config['body/block'] = dict(layout='cna', pool_size=2, pool_strides=2)
        config['head'] = dict(layout='Vdf', dropout_rate=.8, units=2)

        config['loss'] = 'ce'

        return config
github analysiscenter / batchflow / batchflow / models / tf / mobilenet.py View on Github external
from copy import deepcopy
import tensorflow as tf

from ... import is_best_practice
from . import TFModel
from .layers import conv_block


_V1_DEFAULT_BODY = {
    'strides': [1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 2],
    'double_filters': [1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0],
    'width_factor': 1
}


class MobileNet(TFModel):
    """ MobileNet

    **Configuration**

    inputs : dict
        dict with 'images' and 'labels' (see :meth:`~.TFModel._make_inputs`)

    initial_block : dict
        parameters for the initial block (default is 'cna', 32, 3, strides=2)

    body : dict
        strides : list of int
            strides in separable convolutions

        double_filters : list of bool
            if True, number of filters in 1x1 covolution will be doubled
github analysiscenter / batchflow / batchflow / models / tf / gcn.py View on Github external
def default_config(cls):
        config = TFModel.default_config()

        config['initial_block'] = dict(layout='cna', filters=64, kernel_size=7, strides=2)
        config['body/encoder'] = dict(base_class=ResNet101, filters=[256, 512, 1024, 2048])
        config['body/block'] = dict(layout='cn cn', filters=21, kernel_size=11)
        config['body/res_block'] = False
        config['body/br'] = dict(layout='ca c', kernel_size=3, bottleneck=False, downsample=False)
        config['body/upsample'] = dict(layout='tna', factor=2, kernel_size=4)

        config['head/upsample'] = dict(layout='tna', factor=2, kernel_size=4)

        config['loss'] = 'ce'

        return config