Exemple #1
0
import os, sys
import tensorflow as tf
from AnetLib.options.train_options import Options
from AnetLib.models.models import create_model
from smlm_datasets import create_data_sources

default_workdir = './output/' + os.path.basename(sys.argv[0])
opt = Options().parse()
opt.fineSize = 512
opt.batchSize = 1  # batchSize = 1
opt.model = 'a_net_tensorflow'
opt.dim_ordering = 'channels_last'
opt.display_freq = 500
opt.save_latest_freq = 1000
opt.use_resize_conv = True
opt.norm_A = 'mean_std'
opt.norm_B = 'min_max[0,1]'
opt.lambda_A = 50
opt.input_nc = 2
opt.lr_nc = 1
opt.lr_scale = 1.0/4.0
opt.lambda_LR = 25
opt.control_nc = 1
opt.add_data_type_control = True
opt.add_lr_channel = False
opt.use_random_channel_mask = True
opt.lr_loss_mode = 'lr_predict'

if opt.phase == 'train':
    sources = create_data_sources('TransformedCSVImages', opt)
    d = sources['train']
Exemple #2
0
def test_training():
    opt = Options().parse(['--workdir=./__test_tmp__/'])
    opt.model = 'a_net_tensorflow'
    opt.fineSize = 256
    opt.batchSize = 1
    opt.dim_ordering = 'channels_last'
    opt.display_freq = 500
    opt.use_resize_conv = True
    opt.norm_A = 'mean_std'
    opt.norm_B = 'min_max[0,1]'
    opt.lambda_A = 50
    opt.input_nc = 2
    opt.lr_nc = 1
    opt.lr_scale = 1.0 / 4.0
    opt.lambda_LR = 0
    opt.control_nc = 1
    opt.add_data_type_control = True
    opt.add_lr_channel = 'pseudo'
    # reduce the anet size
    opt.ngf = 1
    opt.ndf = 1
    # opt.continue_train = True

    # start training
    sources = create_data_sources(['TransformedTubulin001NB'], opt)
    d = sources['train']
    model = create_model(opt)
    model.train(d, verbose=1, max_steps=1)

    # training done
    opt.phase = 'test'
    model = create_model(opt)
    sources = create_data_sources(['TransformedTubulin001NB'], opt)
    d = sources['test']
    model.predict(d, verbose=1, max_steps=1)
Exemple #3
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Freeze A-Net models
python3 freeze.py --workdir=./results/frozen_model_1 --load_dir=./results/simulated_model
'''
import os
import sys
import tensorflow as tf
from AnetLib.options.train_options import Options
from AnetLib.models.models import create_model
from smlm_datasets import create_data_sources
from AnetLib.util.freeze_graph import freeze_latest_checkpoint

default_workdir = './workdir'
opt = Options().parse()
opt.model = 'anet_tensorflow'
opt.fineSize = 512
opt.batchSize = 1
opt.dim_ordering = 'channels_last'
opt.display_freq = 500
opt.use_resize_conv = True
opt.norm_A = 'mean_std'
opt.norm_B = 'min_max[0,1]'
opt.lambda_A = 50
opt.input_nc = 2
opt.lr_nc = 1
opt.lr_scale = 1.0/4.0
opt.lambda_LR = 0
opt.control_nc = 1
opt.add_data_type_control = True