コード例 #1
0
def main(args):

    utils.ensure_dir(
        [join(args.model_path, args.id),
         join(args.pred_path, args.id)])

    print('-' * 30)
    print('Loading and preprocessing test data...')
    print('-' * 30)
    try:
        imgs_test, imgs_id_test = utils.load_test_data(args.data_path)
    except FileNotFoundError:
        utils.create_test_data(args.data_path, args.data_path)
        imgs_test, imgs_id_test = utils.load_test_data(args.data_path)

    print('-' * 30)
    print('Loading saved model...')
    print('-' * 30)
    net = model_build.load_model(join(args.model_path, args.id))

    output_shape = net.layers[0].output_shape[1:-1]
    if len(output_shape) == 2:
        imgs_test = utils.preprocess_x(imgs_test, new_shape=output_shape)
    else:
        imgs_test = utils.preprocess_x(imgs_test, new_shape=(96, 96))
    print('-' * 30)
    print('Predicting masks on test data...')
    print('-' * 30)
    imgs_mask_test, presence_test = net.predict(imgs_test, verbose=1)
    print(imgs_mask_test.shape, presence_test.shape)
    np.save(join(args.pred_path, args.id, 'imgs_mask_test.npy'),
            imgs_mask_test)
    np.save(join(args.pred_path, args.id, 'imgs_presence_test.npy'),
            presence_test)
    """print('-' * 30)
コード例 #2
0
ファイル: test_app.py プロジェクト: jeckt/flask-wallets
    def setUp(self):
        self.temp_path = utils.create_test_data()

        self.app = App('steve', conn=self.temp_path)

        self.template = 'salary'
        self.funding = self.app.funding_templates[self.template]
コード例 #3
0
    def setUp(self):
        self.temp_path = utils.create_test_data()

        self.app = App('steve', conn=self.temp_path)
        self.wallet = 'shares'
        self.transfer = 'savings'
        self.funding = self.app.funding_templates['salary']
コード例 #4
0
ファイル: test.py プロジェクト: summelon/DLP_Lab
def eval_bleu(encoder, decoder, device):
    encoder.eval(), decoder.eval()
    # Get input & target data
    i_words, t_words, i_tenses, t_tenses = utils.create_test_data(device)
    with torch.no_grad():
        latents, _, _ = encoder(i_words, i_tenses)
        outputs, _, _ = decoder(latents, t_tenses)
        preds = torch.argmax(outputs, dim=-1)
        accuracy = torch.sum(preds == t_words).double() / t_words.numel()
        bleu_acc = utils.compute_batch_bleu(preds, t_words) / t_words.shape[1]
    print(utils.idx2char(preds))
    print(utils.idx2char(t_words))
    print(f"Accuracy is {accuracy:.2%}")
    print(f"BLEU Accuracy is {bleu_acc:.2%}")

    return accuracy, bleu_acc
コード例 #5
0
 def setUp(self):
     self.temp_path = utils.create_test_data()
     self.user = '******'
     self.app = App(self.user, conn=self.temp_path)
コード例 #6
0
 def setUp(self):
     self.temp_path = utils.create_test_data()
コード例 #7
0
ファイル: test_app.py プロジェクト: jeckt/flask-wallets
    def setUp(self):
        self.temp_path = utils.create_test_data()

        self.app = App('steve', conn=self.temp_path)
        self.wallets = self.app.wallets
コード例 #8
0
 def setUpClass(self):
     self.temp_path = utils.create_test_data()
     self.app = App('steve', conn=self.temp_path)
     self.accounts = self.app.accounts