コード例 #1
0
def build_SAE_network(config):
    nb_layers = 5
    autoencoder, encoder, decoder = utilModelREDNet.build_REDNet(
        nb_layers, config.window, config.nb_filters, config.kernel,
        config.dropout, config.stride, config.every)

    autoencoder.compile(optimizer='adam', loss=util.micro_fm, metrics=['mse'])

    pkg_models = os.listdir(
        os.path.join(os.path.dirname(os.path.abspath(__file__)), 'MODELS'))
    if config.modelpath.replace('MODELS/', '') in pkg_models:
        config.modelpath = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), config.modelpath)

    autoencoder.load_weights(config.modelpath)

    return autoencoder
コード例 #2
0
def build_SAE_network(config, weights_filename):
    nb_layers = 5
    autoencoder, encoder, decoder = utilModelREDNet.build_REDNet(
        nb_layers, config.window, config.nb_filters, config.kernel,
        config.dropout, config.stride, config.every)

    autoencoder.compile(optimizer='adam', loss=util.micro_fm, metrics=['mse'])
    print(autoencoder.summary())

    if config.loadmodel != None:
        print('Loading initial weights from', config.loadmodel)
        autoencoder.load_weights(config.loadmodel)
    elif config.test == True:
        print('Loading test weights from', weights_filename)
        autoencoder.load_weights(weights_filename)

    return autoencoder
コード例 #3
0
                    help='save the output image')
args = parser.parse_args()

if args.step == -1:
    args.step = args.window

if args.demo == False and args.outFilename == None:
    util.print_error(
        "ERROR: no output mode selected\nPlease choose between -demo or -save options"
    )
    parser.print_help()
    quit()

nb_layers = 5
autoencoder, encoder, decoder = utilModelREDNet.build_REDNet(
    nb_layers, args.window, args.nb_filters, args.kernel, args.dropout,
    args.stride, args.every)

autoencoder.compile(optimizer='adam', loss=util.micro_fm, metrics=['mse'])

autoencoder.load_weights(args.modelpath)

img = cv2.imread(args.imgpath, False)
img = np.asarray(img)

rows = img.shape[0]
cols = img.shape[1]
if img.shape[0] < args.window or img.shape[1] < args.window:  # Scale approach
    new_rows = args.window if img.shape[0] < args.window else img.shape[0]
    new_cols = args.window if img.shape[1] < args.window else img.shape[1]
    img = cv2.resize(img, (new_cols, new_rows), interpolation=cv2.INTER_CUBIC)