Example #1
0
    model.train = False

    xp = cuda.cupy if args.gpu >= 0 else np

    if not os.path.exists(args.out_dir):
        os.makedirs(args.out_dir)

    tile_conv1 = tile_W(model.conv1.W.data)
    cv.imwrite('{}/conv1_W.png'.format(args.out_dir), tile_conv1)

    o_side = args.ortho_original_side
    l_side = args.label_original_side
    om_side = args.ortho_side
    lm_side = args.label_side

    o_cur, o_txn, _ = get_cursor('data/mass_merged/lmdb/test_sat')
    l_cur, l_txn, _ = get_cursor('data/mass_merged/lmdb/test_map')

    i = 0
    while True:
        o_key, o_val = o_cur.item()
        l_key, l_val = l_cur.item()
        if o_key != l_key:
            raise ValueError('Keys of ortho and label patches are different: '
                             '{} != {}'.format(o_key, l_key))

        # prepare patch
        o_patch = np.fromstring(o_val, dtype=np.uint8).reshape(
            (o_side, o_side, 3))
        l_patch = np.fromstring(l_val, dtype=np.uint8).reshape(
            (l_side, l_side, 1))
Example #2
0
    model.train = False

    xp = cuda.cupy if args.gpu >= 0 else np

    if not os.path.exists(args.out_dir):
        os.makedirs(args.out_dir)

    tile_conv1 = tile_W(model.conv1.W.data)
    cv.imwrite('{}/conv1_W.png'.format(args.out_dir), tile_conv1)

    o_side = args.ortho_original_side
    l_side = args.label_original_side
    om_side = args.ortho_side
    lm_side = args.label_side

    o_cur, o_txn, _ = get_cursor('data/mass_merged/lmdb/test_sat')
    l_cur, l_txn, _ = get_cursor('data/mass_merged/lmdb/test_map')

    i = 0
    while True:
        o_key, o_val = o_cur.item()
        l_key, l_val = l_cur.item()
        if o_key != l_key:
            raise ValueError(
                'Keys of ortho and label patches are different: '
                '{} != {}'.format(o_key, l_key))

        # prepare patch
        o_patch = np.fromstring(
            o_val, dtype=np.uint8).reshape((o_side, o_side, 3))
        l_patch = np.fromstring(
Example #3
0
# -*- coding: utf-8 -*-

import argparse

import numpy as np

from train import get_cursor

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--db_fn', type=str)
    parser.add_argument('--side', type=int, default=92)
    args = parser.parse_args()
    side = args.side

    cur, txn, args.N = get_cursor(args.db_fn)

    i = 0
    norms = []
    while True:
        key, val = cur.item()
        patch = np.fromstring(val, dtype=np.uint8).reshape((side, side, 3))
        patch = patch.astype(np.float)
        patch -= patch.reshape((-1, 3)).mean(axis=0)
        patch /= patch.reshape((-1, 3)).std(axis=0)
        norms.append(np.linalg.norm(patch))
        ret = cur.next()
        if not ret:
            break
        print(i)
        i += 1