Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
add unittest for tf inception
Browse files Browse the repository at this point in the history
  • Loading branch information
Larryjianfeng committed Jul 11, 2019
1 parent eaffbbf commit 2dd9e00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_image_encoder_tf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import numpy as np
from gnes.encoder.image.inception import TFInceptionEncoder
import unittest


class TestTFImageEncoder(unittest.TestCase):
def setUp(self):
dirname = os.path.dirname(__file__)
self.yaml_path = os.path.join(dirname, 'yaml', 'tf-inception-encoder.yaml')
self.test_data_1 = [np.random.uniform(0, 1, size=(299, 299, 3)).astype(np.uint8) for _ in range(1)]
self.test_data_2 = [np.random.uniform(0, 1, size=(299, 299, 3)).astype(np.uint8) for _ in range(100)]

def test_encoding(self):
self.encoder = TFInceptionEncoder.load_yaml(self.yaml_path)
ret1 = self.encoder.encode(self.test_data_1)
ret2 = self.encoder.encode(self.test_data_2)
self.assertEqual(ret1.shape[0], 1)
self.assertEqual(ret2.shape[0], 1000)
5 changes: 5 additions & 0 deletions tests/yaml/tf-inception-encoder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
!TFInceptionEncoder
parameter:
model_dir: /ext/inception_v4/inception_v4.ckpt
batch_size: 64
select_layer: PreLogitsFlatten

0 comments on commit 2dd9e00

Please sign in to comment.