|
36 | 36 | from tensorflow.python.tools import freeze_graph |
37 | 37 | from tensorflow.python.trackable import autotrackable |
38 | 38 | from tensorflow.python.saved_model.save import save |
39 | | -import tensorflow_hub as hub |
40 | 39 |
|
41 | 40 | import tensorflowjs as tfjs |
42 | 41 |
|
@@ -124,27 +123,6 @@ def _createTensorFlowSavedModel(save_path): |
124 | 123 |
|
125 | 124 | save(root, save_path, to_save) |
126 | 125 |
|
127 | | - |
128 | | -def _create_hub_module(save_path): |
129 | | - """Create a TensorFlow Hub module for testing. |
130 | | -
|
131 | | - Args: |
132 | | - save_path: The directory path in which to save the model. |
133 | | - """ |
134 | | - # Module function that doubles its input. |
135 | | - def double_module_fn(): |
136 | | - w = tf.Variable([2.0, 4.0]) |
137 | | - x = tf.compat.v1.placeholder(dtype=tf.float32) |
138 | | - hub.add_signature(inputs=x, outputs=x*w) |
139 | | - graph = tf.Graph() |
140 | | - with graph.as_default(): |
141 | | - spec = hub.create_module_spec(double_module_fn) |
142 | | - m = hub.Module(spec) |
143 | | - # Export the module. |
144 | | - with tf.compat.v1.Session(graph=graph) as sess: |
145 | | - sess.run(tf.compat.v1.global_variables_initializer()) |
146 | | - m.export(save_path, sess) |
147 | | - |
148 | 126 | def _create_frozen_model(save_path): |
149 | 127 | graph = tf.Graph() |
150 | 128 | saved_model_dir = os.path.join(save_path) |
@@ -198,7 +176,6 @@ def setUpClass(cls): |
198 | 176 | _createTensorFlowSavedModelV1('b', cls.tf_saved_model_v1_dir) |
199 | 177 | _create_frozen_model(cls.tf_frozen_model_dir) |
200 | 178 | cls.tf_hub_module_dir = os.path.join(cls.class_tmp_dir, 'tf_hub_module') |
201 | | - _create_hub_module(cls.tf_hub_module_dir) |
202 | 179 |
|
203 | 180 | @classmethod |
204 | 181 | def tearDownClass(cls): |
@@ -456,32 +433,6 @@ def testConvertTFSavedModelV1WithCommandLineWorks(self): |
456 | 433 | # Check the content of the output directory. |
457 | 434 | self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) |
458 | 435 |
|
459 | | - |
460 | | - def testConvertTFHubModuleWithCommandLineWorks(self): |
461 | | - output_dir = os.path.join(self._tmp_dir) |
462 | | - process = subprocess.Popen([ |
463 | | - 'tensorflowjs_converter', '--input_format', 'tf_hub', |
464 | | - self.tf_hub_module_dir, output_dir |
465 | | - ]) |
466 | | - process.communicate() |
467 | | - self.assertEqual(0, process.returncode) |
468 | | - |
469 | | - weights = [{ |
470 | | - 'paths': ['group1-shard1of1.bin'], |
471 | | - 'weights': [{ |
472 | | - 'shape': [2], |
473 | | - 'name': 'module/Variable', |
474 | | - 'dtype': 'float32' |
475 | | - }] |
476 | | - }] |
477 | | - # Load the saved weights as a JSON string. |
478 | | - output_json = json.load( |
479 | | - open(os.path.join(output_dir, 'model.json'), 'rt')) |
480 | | - self.assertEqual(output_json['weightsManifest'], weights) |
481 | | - |
482 | | - # Check the content of the output directory. |
483 | | - self.assertTrue(glob.glob(os.path.join(output_dir, 'group*-*'))) |
484 | | - |
485 | 436 | def testConvertTFSavedModelWithCommandLineWorks(self): |
486 | 437 | output_dir = os.path.join(self._tmp_dir) |
487 | 438 | process = subprocess.Popen([ |
|
0 commit comments