diff --git a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/.keep b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/GPU\347\262\276\345\272\246.txt" "b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/GPU\347\262\276\345\272\246.txt" new file mode 100644 index 0000000000000000000000000000000000000000..de31ae6b33404472cf36d280cf674f54c36ce8c8 --- /dev/null +++ "b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/GPU\347\262\276\345\272\246.txt" @@ -0,0 +1,106 @@ +Evaluated 39900 examples +Mean error: %f degrees 5.551389 +Median error: %f degrees 3.6492655 +Std: %f degrees 10.683777 + +Percentiles: + 1%: 0.703878 + 2%: 0.889114 + 3%: 1.011817 + 4%: 1.117676 + 5%: 1.203335 + 6%: 1.290285 + 7%: 1.362000 + 8%: 1.423815 + 9%: 1.484244 + 10%: 1.540022 + 11%: 1.593973 + 12%: 1.645681 + 13%: 1.698696 + 14%: 1.743833 + 15%: 1.792095 + 16%: 1.841431 + 17%: 1.893619 + 18%: 1.939569 + 19%: 1.985442 + 20%: 2.029315 + 21%: 2.077730 + 22%: 2.125596 + 23%: 2.174029 + 24%: 2.223344 + 25%: 2.272967 + 26%: 2.323889 + 27%: 2.370916 + 28%: 2.424628 + 29%: 2.477176 + 30%: 2.526464 + 31%: 2.579367 + 32%: 2.632026 + 33%: 2.682996 + 34%: 2.733374 + 35%: 2.784669 + 36%: 2.837522 + 37%: 2.893403 + 38%: 2.948823 + 39%: 3.002961 + 40%: 3.058895 + 41%: 3.115458 + 42%: 3.170274 + 43%: 3.233495 + 44%: 3.287655 + 45%: 3.344627 + 46%: 3.402717 + 47%: 3.463511 + 48%: 3.525312 + 49%: 3.588614 + 50%: 3.649158 + 51%: 3.710984 + 52%: 3.777194 + 53%: 3.840634 + 54%: 3.912314 + 55%: 3.978772 + 56%: 4.050912 + 57%: 4.124833 + 58%: 4.205145 + 59%: 4.269850 + 60%: 4.350731 + 61%: 4.429609 + 62%: 4.506891 + 63%: 4.590645 + 64%: 4.673866 + 65%: 4.769208 + 66%: 4.860751 + 67%: 4.957645 + 68%: 5.045778 + 69%: 5.145709 + 70%: 5.248520 + 71%: 5.356171 + 72%: 5.463465 + 73%: 5.576540 + 74%: 5.700179 + 75%: 5.826519 + 76%: 5.954271 + 77%: 6.075412 + 78%: 6.217035 + 79%: 6.359586 + 80%: 6.509334 + 81%: 6.681930 + 82%: 6.855579 + 83%: 7.045702 + 84%: 7.237360 + 85%: 7.455194 + 86%: 7.683445 + 87%: 7.928701 + 88%: 8.226621 + 89%: 8.539159 + 90%: 8.927838 + 91%: 9.329886 + 92%: 9.826632 + 93%: 10.504982 + 94%: 11.362451 + 95%: 12.505600 + 96%: 14.257383 + 97%: 17.200018 + 98%: 22.386629 + 99%: 37.106316 +100%: 179.459671 diff --git a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/gen_pt_test_data_gpu.py b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/gen_pt_test_data_gpu.py new file mode 100644 index 0000000000000000000000000000000000000000..ccef0b62fc5fdd950097f668e9a8494e2ccc4642 --- /dev/null +++ b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/gen_pt_test_data_gpu.py @@ -0,0 +1,124 @@ +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +# coding=utf-8 +# Copyright 2021 The Google Research Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Generate modified point cloud test data with fixed random rotations.""" +import glob +import os +import pathlib + +import utils_gpu +from absl import app +from absl import flags +import numpy as np +from scipy.stats import special_ortho_group + +FLAGS = flags.FLAGS +flags.DEFINE_string('input_test_files1', '', + 'Regular expression for the original input points files.') +flags.DEFINE_string('input_test_files2', '', + 'Regular expression for the original input test files.') +flags.DEFINE_string('output_directory1', '', + 'Output directory where new points files will be stored.') +flags.DEFINE_string('output_directory2', '', + 'Output directory where new test files will be stored.') +flags.DEFINE_integer('num_rotations_per_file', 100, + 'Number of random rotation augmentations per test point ' + 'cloud.') +flags.DEFINE_boolean('random_rotation_axang', True, + 'If true, samples random rotations using the method ' + 'from the original benchmark code. Otherwise samples ' + 'by Haar measure.') + +def gen_test_data(): + """Generate the new (modified) test data.""" + # Create output directory. + os.makedirs(FLAGS.output_directory1, exist_ok=True) + os.makedirs(FLAGS.output_directory2, exist_ok=True) + + # Get all test point cloud files in the original dataset. + input_test_files1 = glob.glob(FLAGS.input_test_files1) + input_test_files2 = glob.glob(FLAGS.input_test_files2) + + n = 1 + for in_file in input_test_files1: + pts = np.loadtxt(in_file) + m = pts.shape[0] + if n < m: + n = m + print("over") + + for in_file in input_test_files1: + out_file_prefix = pathlib.Path(in_file).stem + pts = np.loadtxt(in_file) # N x 3 + data1 = np.random.rand(n-pts.shape[0], 3) + pts = np.vstack((pts, data1)) + out_file1 = os.path.join( + FLAGS.output_directory1, '%s.pts' % (out_file_prefix)) + np.savetxt(out_file1, pts) + print("over") + + for in_file in input_test_files2: + out_file_prefix = pathlib.Path(in_file).stem + pts = np.loadtxt(in_file) # N x 3 + num_pts_to_keep = pts.shape[0] // 2 + pts = pts[:num_pts_to_keep, :] # N//2 x 3. + + for k in range(FLAGS.num_rotations_per_file): + if FLAGS.random_rotation_axang: + r = utils_gpu.random_rotation_benchmark_np(1) + r = r[0] + else: + r = special_ortho_group.rvs(3) + joined = np.float32(np.concatenate((r, pts), axis=0)) # (N//2+3) x 3. + out_file = os.path.join( + FLAGS.output_directory2, '%s_r%03d.pts' % (out_file_prefix, k)) + np.savetxt(out_file, joined) + print("over") + + +def main(unused_argv): + gen_test_data() + +if __name__ == '__main__': + app.run(main) \ No newline at end of file diff --git a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/license.txt b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..0384a2533496a16cfcac887909695e21ad212b7d --- /dev/null +++ b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/license.txt @@ -0,0 +1,28 @@ +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ diff --git a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/loss.log b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/loss.log new file mode 100644 index 0000000000000000000000000000000000000000..dc3dfb67dfa6304add585bea3941b5a9eff93a18 --- /dev/null +++ b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/loss.log @@ -0,0 +1,246 @@ +2022-03-19 18:03:26,273 - tensorflow - INFO - Using config: {'_model_dir': '/root/RotationContinuity-master2/shapenet/data/pc_plane/to/model1', '_tf_random_seed': None, '_save_summary_steps': 25, '_save_checkpoints_steps': 100, '_save_checkpoints_secs': None, '_session_config': allow_soft_placement: true +graph_options { + rewrite_options { + meta_optimizer_iterations: ONE + } +} +, '_keep_checkpoint_max': None, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 200, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_session_creation_timeout_secs': 7200, '_service': None, '_cluster_spec': , '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1} +2022-03-19 18:03:26,273 - tensorflow - INFO - Not using Distribute Coordinator. +2022-03-19 18:03:26,273 - tensorflow - INFO - Running training and evaluation locally (non-distributed). +2022-03-19 18:03:26,274 - tensorflow - INFO - Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps 100 or save_checkpoints_secs None. +2022-03-19 18:03:26,277 - tensorflow - INFO - Skipping training since max_steps has already saved. +2022-03-19 18:04:19,049 - tensorflow - INFO - Using config: {'_model_dir': '/root/RotationContinuity-master2/shapenet/data/pc_plane/to/model1', '_tf_random_seed': None, '_save_summary_steps': 25, '_save_checkpoints_steps': 100, '_save_checkpoints_secs': None, '_session_config': allow_soft_placement: true +graph_options { + rewrite_options { + meta_optimizer_iterations: ONE + } +} +, '_keep_checkpoint_max': None, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 200, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_session_creation_timeout_secs': 7200, '_service': None, '_cluster_spec': , '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1} +2022-03-19 18:04:19,050 - tensorflow - INFO - Not using Distribute Coordinator. +2022-03-19 18:04:19,050 - tensorflow - INFO - Running training and evaluation locally (non-distributed). +2022-03-19 18:04:19,050 - tensorflow - INFO - Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps 100 or save_checkpoints_secs None. +2022-03-19 18:04:19,054 - tensorflow - INFO - Skipping training since max_steps has already saved. +2022-03-19 18:04:49,280 - tensorflow - INFO - Using config: {'_model_dir': '/root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2', '_tf_random_seed': None, '_save_summary_steps': 25, '_save_checkpoints_steps': 100, '_save_checkpoints_secs': None, '_session_config': allow_soft_placement: true +graph_options { + rewrite_options { + meta_optimizer_iterations: ONE + } +} +, '_keep_checkpoint_max': None, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 200, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_experimental_max_worker_delay_secs': None, '_session_creation_timeout_secs': 7200, '_service': None, '_cluster_spec': , '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1} +2022-03-19 18:04:49,281 - tensorflow - INFO - Not using Distribute Coordinator. +2022-03-19 18:04:49,281 - tensorflow - INFO - Running training and evaluation locally (non-distributed). +2022-03-19 18:04:49,281 - tensorflow - INFO - Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps 100 or save_checkpoints_secs None. +2022-03-19 18:04:49,286 - tensorflow - WARNING - From /root/anaconda3/envs/tf/lib/python3.7/site-packages/tensorflow_core/python/training/training_util.py:236: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version. +Instructions for updating: +Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts. +2022-03-19 18:04:49,292 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:244: The name tf.gfile.Glob is deprecated. Please use tf.io.gfile.glob instead. + +2022-03-19 18:04:49,683 - tensorflow - WARNING - From /root/anaconda3/envs/tf/lib/python3.7/site-packages/tensorflow_core/python/autograph/converters/directives.py:119: The name tf.read_file is deprecated. Please use tf.io.read_file instead. + +2022-03-19 18:04:49,683 - tensorflow - WARNING - From /root/anaconda3/envs/tf/lib/python3.7/site-packages/tensorflow_core/python/autograph/converters/directives.py:119: The name tf.decode_csv is deprecated. Please use tf.io.decode_csv instead. + +2022-03-19 18:04:49,766 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:223: calling string_split (from tensorflow.python.ops.ragged.ragged_string_ops) with delimiter is deprecated and will be removed in a future version. +Instructions for updating: +delimiter is deprecated, please use sep instead. +2022-03-19 18:04:49,932 - tensorflow - WARNING - From /root/special_orthogonalization2/utils_gpu.py:75: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be removed in a future version. +Instructions for updating: +tf.py_func is deprecated in TF V2. Instead, there are two + options available in V2. + - tf.py_function takes a python function which manipulates tf eager + tensors instead of numpy arrays. It's easy to convert a tf eager tensor to + an ndarray (just call tensor.numpy()) but having access to eager tensors + means `tf.py_function`s can use accelerators such as GPUs as well as + being differentiable using a gradient tape. + - tf.numpy_function maintains the semantics of the deprecated tf.py_func + (it is not differentiable, and manipulates numpy arrays). It drops the + stateful argument making all functions stateful. + +2022-03-19 18:04:49,938 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:252: The name tf.data.make_one_shot_iterator is deprecated. Please use tf.compat.v1.data.make_one_shot_iterator instead. + +2022-03-19 18:04:49,961 - tensorflow - INFO - Calling model_fn. +2022-03-19 18:04:49,966 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:74: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead. + +2022-03-19 18:04:49,966 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:74: The name tf.AUTO_REUSE is deprecated. Please use tf.compat.v1.AUTO_REUSE instead. + +2022-03-19 18:04:49,966 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:75: conv1d (from tensorflow.python.layers.convolutional) is deprecated and will be removed in a future version. +Instructions for updating: +Use `tf.keras.layers.Conv1D` instead. +2022-03-19 18:04:49,967 - tensorflow - WARNING - From /root/anaconda3/envs/tf/lib/python3.7/site-packages/tensorflow_core/python/layers/convolutional.py:218: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version. +Instructions for updating: +Please use `layer.__call__` method instead. +2022-03-19 18:04:50,011 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:81: calling reduce_max_v1 (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version. +Instructions for updating: +keep_dims is deprecated, use keepdims instead +2022-03-19 18:04:50,033 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:99: dense (from tensorflow.python.layers.core) is deprecated and will be removed in a future version. +Instructions for updating: +Use keras.layers.Dense instead. +2022-03-19 18:04:50,055 - tensorflow - WARNING - From /root/special_orthogonalization2/utils_gpu.py:97: The name tf.svd is deprecated. Please use tf.linalg.svd instead. + +2022-03-19 18:04:50,079 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:171: The name tf.summary.scalar is deprecated. Please use tf.compat.v1.summary.scalar instead. + +2022-03-19 18:04:50,082 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:173: The name tf.train.get_or_create_global_step is deprecated. Please use tf.compat.v1.train.get_or_create_global_step instead. + +2022-03-19 18:04:50,083 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:185: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead. + +2022-03-19 18:04:50,083 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:186: The name tf.get_collection is deprecated. Please use tf.compat.v1.get_collection instead. + +2022-03-19 18:04:50,083 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:186: The name tf.GraphKeys is deprecated. Please use tf.compat.v1.GraphKeys instead. + +2022-03-19 18:04:50,323 - tensorflow - INFO - Done calling model_fn. +2022-03-19 18:04:50,325 - tensorflow - INFO - Create CheckpointSaverHook. +2022-03-19 18:04:50,418 - tensorflow - WARNING - From /root/anaconda3/envs/tf/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py:1475: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version. +Instructions for updating: +Use tf.where in 2.0, which has the same broadcast rule as np.where +2022-03-19 18:04:50,485 - tensorflow - INFO - Graph was finalized. +2022-03-19 18:04:52,089 - tensorflow - INFO - Running local_init_op. +2022-03-19 18:04:52,106 - tensorflow - INFO - Done running local_init_op. +2022-03-19 18:04:52,544 - tensorflow - INFO - Saving checkpoints for 0 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:04:52,608 - tensorflow - INFO - model.ckpt-0 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:04:55,512 - tensorflow - INFO - loss = 32.202156, step = 0 +2022-03-19 18:04:57,008 - tensorflow - INFO - Saving checkpoints for 100 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:04:57,026 - tensorflow - INFO - model.ckpt-100 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:04:57,484 - tensorflow - INFO - Calling model_fn. +2022-03-19 18:04:57,596 - tensorflow - WARNING - From /root/special_orthogonalization2/main_point_cloud_gpu.py:203: The name tf.metrics.mean is deprecated. Please use tf.compat.v1.metrics.mean instead. + +2022-03-19 18:04:57,606 - tensorflow - INFO - Done calling model_fn. +2022-03-19 18:04:57,621 - tensorflow - INFO - Starting evaluation at 2022-03-19T18:04:57Z +2022-03-19 18:04:57,684 - tensorflow - INFO - Graph was finalized. +2022-03-19 18:04:57,687 - tensorflow - INFO - Restoring parameters from /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt-100 +2022-03-19 18:04:57,883 - tensorflow - INFO - Running local_init_op. +2022-03-19 18:04:57,949 - tensorflow - INFO - Done running local_init_op. +2022-03-19 18:04:59,509 - tensorflow - INFO - Evaluation [39/399] +2022-03-19 18:05:00,470 - tensorflow - INFO - Evaluation [78/399] +2022-03-19 18:05:00,986 - tensorflow - INFO - Evaluation [117/399] +2022-03-19 18:05:01,473 - tensorflow - INFO - Evaluation [156/399] +2022-03-19 18:05:01,813 - tensorflow - INFO - Evaluation [195/399] +2022-03-19 18:05:02,217 - tensorflow - INFO - Evaluation [234/399] +2022-03-19 18:05:02,537 - tensorflow - INFO - Evaluation [273/399] +2022-03-19 18:05:02,756 - tensorflow - INFO - Evaluation [312/399] +2022-03-19 18:05:02,876 - tensorflow - INFO - Evaluation [351/399] +2022-03-19 18:05:03,157 - tensorflow - INFO - Evaluation [390/399] +2022-03-19 18:05:03,209 - tensorflow - INFO - Evaluation [399/399] +2022-03-19 18:05:03,291 - tensorflow - INFO - Finished evaluation at 2022-03-19-18:05:03 +2022-03-19 18:05:03,292 - tensorflow - INFO - Saving dict for global step 100: global_step = 100, loss = 2.0213404, mean_degree_err = 90.8583 +2022-03-19 18:05:03,399 - tensorflow - INFO - Saving 'checkpoint_path' summary for global step 100: /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt-100 +2022-03-19 18:05:04,530 - tensorflow - INFO - Saving checkpoints for 200 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:04,547 - tensorflow - INFO - model.ckpt-200 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:04,586 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:04,600 - tensorflow - INFO - global_step/sec: 22.0056 +2022-03-19 18:05:04,601 - tensorflow - INFO - loss = 18.108334, step = 200 (9.089 sec) +2022-03-19 18:05:05,711 - tensorflow - INFO - Saving checkpoints for 300 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:05,728 - tensorflow - INFO - model.ckpt-300 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:05,765 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:06,893 - tensorflow - INFO - Saving checkpoints for 400 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:06,911 - tensorflow - INFO - model.ckpt-400 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:06,948 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:06,962 - tensorflow - INFO - global_step/sec: 84.6573 +2022-03-19 18:05:06,963 - tensorflow - INFO - loss = 19.658773, step = 400 (2.362 sec) +2022-03-19 18:05:08,073 - tensorflow - INFO - Saving checkpoints for 500 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:08,089 - tensorflow - INFO - model.ckpt-500 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:08,126 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:09,261 - tensorflow - INFO - Saving checkpoints for 600 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:09,276 - tensorflow - INFO - model.ckpt-600 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:09,314 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:09,329 - tensorflow - INFO - global_step/sec: 84.4893 +2022-03-19 18:05:09,330 - tensorflow - INFO - loss = 15.302707, step = 600 (2.367 sec) +2022-03-19 18:05:10,443 - tensorflow - INFO - Saving checkpoints for 700 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:10,461 - tensorflow - INFO - model.ckpt-700 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:10,498 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:11,624 - tensorflow - INFO - Saving checkpoints for 800 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:11,643 - tensorflow - INFO - model.ckpt-800 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:11,680 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:11,695 - tensorflow - INFO - global_step/sec: 84.5516 +2022-03-19 18:05:11,696 - tensorflow - INFO - loss = 18.000507, step = 800 (2.365 sec) +2022-03-19 18:05:12,807 - tensorflow - INFO - Saving checkpoints for 900 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:12,822 - tensorflow - INFO - model.ckpt-900 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:12,860 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:13,986 - tensorflow - INFO - Saving checkpoints for 1000 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:14,002 - tensorflow - INFO - model.ckpt-1000 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:14,039 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:14,054 - tensorflow - INFO - global_step/sec: 84.7931 +2022-03-19 18:05:14,054 - tensorflow - INFO - loss = 20.527103, step = 1000 (2.359 sec) +2022-03-19 18:05:15,176 - tensorflow - INFO - Saving checkpoints for 1100 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:15,192 - tensorflow - INFO - model.ckpt-1100 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:15,229 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:16,360 - tensorflow - INFO - Saving checkpoints for 1200 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:16,378 - tensorflow - INFO - model.ckpt-1200 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:16,415 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:16,430 - tensorflow - INFO - global_step/sec: 84.1547 +2022-03-19 18:05:16,431 - tensorflow - INFO - loss = 16.00374, step = 1200 (2.377 sec) +2022-03-19 18:05:17,536 - tensorflow - INFO - Saving checkpoints for 1300 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:17,554 - tensorflow - INFO - model.ckpt-1300 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:17,591 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:18,715 - tensorflow - INFO - Saving checkpoints for 1400 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:18,731 - tensorflow - INFO - model.ckpt-1400 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:18,768 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:18,782 - tensorflow - INFO - global_step/sec: 85.0196 +2022-03-19 18:05:18,783 - tensorflow - INFO - loss = 8.673609, step = 1400 (2.352 sec) +2022-03-19 18:05:19,894 - tensorflow - INFO - Saving checkpoints for 1500 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:19,909 - tensorflow - INFO - model.ckpt-1500 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:19,947 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:21,070 - tensorflow - INFO - Saving checkpoints for 1600 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:21,092 - tensorflow - INFO - model.ckpt-1600 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:21,129 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:21,144 - tensorflow - INFO - global_step/sec: 84.7018 +2022-03-19 18:05:21,144 - tensorflow - INFO - loss = 12.576811, step = 1600 (2.361 sec) +2022-03-19 18:05:22,260 - tensorflow - INFO - Saving checkpoints for 1700 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:22,276 - tensorflow - INFO - model.ckpt-1700 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:22,313 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:23,442 - tensorflow - INFO - Saving checkpoints for 1800 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:23,458 - tensorflow - INFO - model.ckpt-1800 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:23,496 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:23,510 - tensorflow - INFO - global_step/sec: 84.5082 +2022-03-19 18:05:23,511 - tensorflow - INFO - loss = 25.950819, step = 1800 (2.367 sec) +2022-03-19 18:05:24,627 - tensorflow - INFO - Saving checkpoints for 1900 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:24,642 - tensorflow - INFO - model.ckpt-1900 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:24,679 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:25,810 - tensorflow - INFO - Saving checkpoints for 2000 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:25,825 - tensorflow - INFO - model.ckpt-2000 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:25,863 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:25,877 - tensorflow - INFO - global_step/sec: 84.5026 +2022-03-19 18:05:25,878 - tensorflow - INFO - loss = 10.249855, step = 2000 (2.367 sec) +2022-03-19 18:05:26,991 - tensorflow - INFO - Saving checkpoints for 2100 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:27,007 - tensorflow - INFO - model.ckpt-2100 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:27,044 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:28,175 - tensorflow - INFO - Saving checkpoints for 2200 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:28,190 - tensorflow - INFO - model.ckpt-2200 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:28,227 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:28,241 - tensorflow - INFO - global_step/sec: 84.5981 +2022-03-19 18:05:28,242 - tensorflow - INFO - loss = 10.412505, step = 2200 (2.364 sec) +2022-03-19 18:05:29,344 - tensorflow - INFO - Saving checkpoints for 2300 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:29,360 - tensorflow - INFO - model.ckpt-2300 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:29,397 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:30,505 - tensorflow - INFO - Saving checkpoints for 2400 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:30,520 - tensorflow - INFO - model.ckpt-2400 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:30,558 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:30,572 - tensorflow - INFO - global_step/sec: 85.8075 +2022-03-19 18:05:30,573 - tensorflow - INFO - loss = 24.763023, step = 2400 (2.331 sec) +2022-03-19 18:05:31,663 - tensorflow - INFO - Saving checkpoints for 2500 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:31,679 - tensorflow - INFO - model.ckpt-2500 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:31,716 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:32,818 - tensorflow - INFO - Saving checkpoints for 2600 into /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt. +2022-03-19 18:05:32,834 - tensorflow - INFO - model.ckpt-2600 is not in all_model_checkpoint_paths. Manually adding it. +2022-03-19 18:05:32,871 - tensorflow - INFO - Skip the current checkpoint eval due to throttle secs (60 secs). +2022-03-19 18:05:33,174 - tensorflow - INFO - Calling model_fn. +2022-03-19 18:05:33,301 - tensorflow - INFO - Done calling model_fn. +2022-03-19 18:05:33,316 - tensorflow - INFO - Starting evaluation at 2022-03-19T18:05:33Z +2022-03-19 18:05:33,379 - tensorflow - INFO - Graph was finalized. +2022-03-19 18:05:33,382 - tensorflow - INFO - Restoring parameters from /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt-2600 +2022-03-19 18:05:33,562 - tensorflow - INFO - Running local_init_op. +2022-03-19 18:05:33,627 - tensorflow - INFO - Done running local_init_op. +2022-03-19 18:05:34,142 - tensorflow - INFO - Evaluation [39/399] +2022-03-19 18:05:34,232 - tensorflow - INFO - Evaluation [78/399] +2022-03-19 18:05:34,318 - tensorflow - INFO - Evaluation [117/399] +2022-03-19 18:05:34,406 - tensorflow - INFO - Evaluation [156/399] +2022-03-19 18:05:34,493 - tensorflow - INFO - Evaluation [195/399] +2022-03-19 18:05:34,581 - tensorflow - INFO - Evaluation [234/399] +2022-03-19 18:05:34,669 - tensorflow - INFO - Evaluation [273/399] +2022-03-19 18:05:34,757 - tensorflow - INFO - Evaluation [312/399] +2022-03-19 18:05:34,844 - tensorflow - INFO - Evaluation [351/399] +2022-03-19 18:05:34,930 - tensorflow - INFO - Evaluation [390/399] +2022-03-19 18:05:34,951 - tensorflow - INFO - Evaluation [399/399] +2022-03-19 18:05:35,034 - tensorflow - INFO - Finished evaluation at 2022-03-19-18:05:35 +2022-03-19 18:05:35,035 - tensorflow - INFO - Saving dict for global step 2600: global_step = 2600, loss = 1.1534922, mean_degree_err = 59.039207 +2022-03-19 18:05:35,035 - tensorflow - INFO - Saving 'checkpoint_path' summary for global step 2600: /root/RotationContinuity-master2/shapenet/data/pc_plane/to/model2/model.ckpt-2600 +2022-03-19 18:05:35,035 - tensorflow - DEBUG - Calling exporter with the `is_the_final_export=True`. +2022-03-19 18:05:35,053 - tensorflow - INFO - Loss for final step: 4.256054. diff --git a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/main_point_cloud_gpu.py b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/main_point_cloud_gpu.py new file mode 100644 index 0000000000000000000000000000000000000000..a27b51b95d10c97218eb3a6d54246bbe72774108 --- /dev/null +++ b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/main_point_cloud_gpu.py @@ -0,0 +1,423 @@ +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +# coding=utf-8 +# Copyright 2021 The Google Research Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Training and evaluation for the point cloud alignment experiment.""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import utils_gpu +import time +from absl import flags +import numpy as np +import tensorflow as tf +import logging +FLAGS = flags.FLAGS +log = logging.getLogger('tensorflow') +log.setLevel(logging.DEBUG) + +# General flags. +flags.DEFINE_string('method', 'svd', + 'Specifies the method to use for predicting rotations. ' + 'Choices are "svd", "svd-inf", or "gs".') +flags.DEFINE_string('checkpoint_dir', '', + 'Locations for checkpoints, summaries, etc.') +flags.DEFINE_integer('train_steps', 2600000, 'Number of training iterations.') +flags.DEFINE_integer('save_checkpoints_steps', 10000, + 'How often to save checkpoints') +flags.DEFINE_integer('log_step_count', 500, 'How often to log the step count') +flags.DEFINE_integer('save_summaries_steps', 5000, + 'How often to save summaries.') +flags.DEFINE_float('learning_rate', 1e-5, 'Learning rate') +flags.DEFINE_boolean('lr_decay', False, 'Decay the learning rate if True.') +flags.DEFINE_integer('lr_decay_steps', 35000, + 'Learning rate decays steps.') +flags.DEFINE_float('lr_decay_rate', 0.95, + 'Learning rate decays rate.') +flags.DEFINE_boolean('predict_all_test', False, + 'If true, runs an eval job on latest checkpoint and ' + 'prints the error for each input.') +flags.DEFINE_integer('eval_examples', 0, 'Number of test examples.') +flags.DEFINE_boolean('print_variable_names', False, + 'Print model variable names.') + +# Flags only used in the point cloud alignment experiment. +flags.DEFINE_integer('num_train_augmentations', 10, + 'Number of random rotations for augmenting each input ' + 'point cloud.') +flags.DEFINE_string('pt_cloud_train_files', '', + 'Expression matching all training point files, e.g. ' + '/path/to/files/pc_plane/points/*.pts') +flags.DEFINE_string('pt_cloud_test_files', '', + 'Expression matching all modified test point files, e.g. ' + '/path/to/files/pc_plane/points_test/*.pts') +flags.DEFINE_boolean('random_rotation_axang', True, + 'If true, samples random rotations using the method ' + 'from the original benchmark code. Otherwise samples ' + 'by Haar measure.') + + +def pt_features(batch_pts): + """Input shape: [B, N, 3], output shape: [B, 1024].""" + with tf.variable_scope('ptenc', reuse=tf.AUTO_REUSE): + f1 = tf.layers.conv1d(inputs=batch_pts, filters=64, kernel_size=1) + f1 = tf.nn.leaky_relu(f1) + f2 = tf.layers.conv1d(inputs=f1, filters=128, kernel_size=1) + f2 = tf.nn.leaky_relu(f2) + f3 = tf.layers.conv1d(inputs=f2, filters=1024, kernel_size=1) + + f = tf.reduce_max(f3, axis=1, keep_dims=False) + return f + + +def regress_from_features(batch_features, out_dim): + """Regress to a rotation representation from point cloud encodings. + + In Zhou et al, CVPR19, the paper describes this regression network as an MLP + mapping 2048->512->512->out_dim, but the associated code implements it with + one less layer: 2048->512->out_dim. We mimic the code. + + Args: + batch_features: [batch_size, in_dim]. + out_dim: desired output dimensionality. + + Returns: + A [batch_size, out_dim] tensor. + """ + f1 = tf.layers.dense(batch_features, 512) + f1 = tf.nn.leaky_relu(f1) + f2 = tf.layers.dense(f1, out_dim) + return f2 + + +def net_point_cloud(points1, points2, mode): + """Predict a relative rotation given two point clouds. + + Args: + points1: [batch_size, N, 3] float tensor. + points2: [batch_size, N, 3] float tensor. + mode: tf.estimator.ModeKeys. + + Returns: + [batch_size, 3, 3] matrices. + """ + f1 = pt_features(points1) + f2 = pt_features(points2) + f = tf.concat([f1, f2], axis=-1) + + if FLAGS.method == 'svd': + p = regress_from_features(f, 9) + return utils_gpu.symmetric_orthogonalization(p) + + if FLAGS.method == 'svd-inf': + p = regress_from_features(f, 9) + if mode == tf.estimator.ModeKeys.TRAIN: + return tf.reshape(p, (-1, 3, 3)) + else: + return utils_gpu.symmetric_orthogonalization(p) + + if FLAGS.method == 'gs': + p = regress_from_features(f, 6) + return utils_gpu.gs_orthogonalization(p) + + +def model_fn(features, labels, mode, params): + """The model_fn used to construct the tf.Estimator.""" + del labels, params # Unused. + if mode == tf.estimator.ModeKeys.TRAIN: + # Training data has point cloud of size [1, N, 3] and random rotations + # of size [1, FLAGS.num_train_augmentations, 3, 3] + rot = features['rot'][0] + num_rot = FLAGS.num_train_augmentations + batch_pts1 = tf.tile(features['data'], [num_rot, 1, 1]) + # In this experiment it does not matter if we pre or post-multiply the + # rotation as long as we are consistent between training and eval. + batch_pts2 = tf.matmul(batch_pts1, rot) # post-multiplying! + else: + # Test data has point cloud of size [1, N, 3] and a single random + # rotation of size [1, 3, 3] + batch_pts1 = features['data'] + rot = features['rot'] + batch_pts2 = tf.matmul(batch_pts1, rot) + rot = tf.reshape(rot, (-1, 3, 3)) + + # Predict the rotation. + r = net_point_cloud(batch_pts1, batch_pts2, mode) + + # Compute the loss. + loss = tf.nn.l2_loss(rot - r) + + # Compute the relative angle in radians. + theta = utils_gpu.relative_angle(r, rot) + + # Mean angle error over the batch. + mean_theta = tf.reduce_mean(theta) + mean_theta_deg = mean_theta * 180.0 / np.pi + + # Train, eval, or predict depending on mode. + if mode == tf.estimator.ModeKeys.TRAIN: + tf.summary.scalar('train/loss', loss) + tf.summary.scalar('train/theta', mean_theta_deg) + global_step = tf.train.get_or_create_global_step() + + if FLAGS.lr_decay: + learning_rate = tf.train.exponential_decay( + FLAGS.learning_rate, + global_step, + FLAGS.lr_decay_steps, + FLAGS.lr_decay_rate) + else: + learning_rate = FLAGS.learning_rate + + tf.summary.scalar('train/learning_rate', learning_rate) + optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate) + update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS) + with tf.control_dependencies(update_ops): + train_op = optimizer.minimize(loss, global_step=global_step) + return tf.estimator.EstimatorSpec( + mode=mode, + loss=loss, + train_op=train_op) + + if mode == tf.estimator.ModeKeys.EVAL: + if FLAGS.predict_all_test: + print_error_op = tf.print('error:', mean_theta_deg) + with tf.control_dependencies([print_error_op]): + eval_metric_ops = { + 'mean_degree_err': tf.metrics.mean(mean_theta_deg), + } + else: + eval_metric_ops = { + 'mean_degree_err': tf.metrics.mean(mean_theta_deg), + } + + return tf.estimator.EstimatorSpec( + mode=mode, + loss=loss, + eval_metric_ops=eval_metric_ops) + + if mode == tf.estimator.ModeKeys.PREDICT: + pred = {'error': mean_theta_deg} + return tf.estimator.EstimatorSpec( + mode=mode, + predictions=pred) + + +def train_input_fn(): + """Generate training data iterator from the .pts files.""" + def _file_to_matrix(pts_path): + """Read Nx3 point cloud from a .pts file.""" + file_buffer = tf.read_file(pts_path) + lines = tf.string_split([file_buffer], delimiter='\n') + lines1 = tf.string_split(lines.values, delimiter='\r') + values = tf.stack(tf.decode_csv(lines1.values, + record_defaults=[[0.0], [0.0], [0.0]], + field_delim=' ')) + values = tf.transpose(values)# 3xN --> Nx3. + # The experiment code in + # github.com/papagina/RotationContinuity/.../shapenet/code/train_pointnet.py + # only used the first half of the points in each file. + return values[:(tf.shape(values)[0]// 2), :] + + + + def _random_rotation(pts): + """Attach N random rotations to a point cloud.""" + if FLAGS.random_rotation_axang: + rotations = utils_gpu.random_rotation_benchmark(FLAGS.num_train_augmentations) + else: + rotations = utils_gpu.random_rotation(FLAGS.num_train_augmentations) + return pts, rotations + + pts_paths = tf.gfile.Glob(FLAGS.pt_cloud_train_files) + dataset = tf.data.Dataset.from_tensor_slices(pts_paths) + dataset = dataset.map(_file_to_matrix) + dataset = dataset.cache() # Comment out if memory cannot hold all the data. + dataset = dataset.shuffle(buffer_size=50, reshuffle_each_iteration=True) + dataset = dataset.repeat() + dataset = dataset.map(_random_rotation) + dataset = dataset.batch(1) + iterator = tf.data.make_one_shot_iterator(dataset) + batch_data, batch_rot = iterator.get_next() + features_dict = {'data': batch_data, 'rot': batch_rot} + batch_size = tf.shape(batch_data)[0] + batch_labels_dummy = tf.zeros(shape=(batch_size, 1)) + return (features_dict, batch_labels_dummy) + + + + +def eval_input_fn(): + """Generate test data from *modified* .pts files. + + See README and comments below for details on how the data is modified. + + Returns: + A tuple of features and associated labels. + """ + def _file_to_matrix(pts_path): + """Read Nx3 point cloud and 3x3 rotation matrix from a .pts file. + + The test data is a modified version of the original files. For each .pts + file we have (1) added a 3x3 rotation matrix for testing, and (2) removed + the second half of the point cloud since it is not used at all. + + Args: + pts_path: path to a .pts file. + + Returns: + A Nx3 point cloud. + A 3x3 rotation matrix. + """ + file_buffer = tf.read_file(pts_path) + lines = tf.string_split([file_buffer], delimiter='\n') + lines1 = tf.string_split(lines.values, delimiter='\r') + values = tf.stack(tf.decode_csv(lines1.values, + record_defaults=[[0.0], [0.0], [0.0]], field_delim=' ')) + values = tf.transpose(values) # 3xN --> Nx3. + # First three rows are the rotation matrix, remaining rows the point cloud. + rot = values[:3, :] + return values[4:, :], rot + + pts_paths = tf.gfile.Glob(FLAGS.pt_cloud_test_files) + dataset = tf.data.Dataset.from_tensor_slices(pts_paths) + dataset = dataset.map(_file_to_matrix) + dataset = dataset.batch(1) + iterator = tf.data.make_one_shot_iterator(dataset) + batch_data, batch_rot = iterator.get_next() + features_dict = {'data': batch_data, 'rot': batch_rot} + batch_size = tf.shape(batch_data)[0] + batch_labels_dummy = tf.zeros(shape=(batch_size, 1)) + return (features_dict, batch_labels_dummy) + + +def print_variable_names(): + """Print variable names in a model.""" + params = {'dummy': 0} + estimator = tf.estimator.Estimator( + model_fn=model_fn, + model_dir=FLAGS.checkpoint_dir, + params=params) + names = estimator.get_variable_names() + for name in names: + print(name) + + +def predict_all_test(): + """Print error statistics for the test dataset.""" + params = {'dummy': 0} + estimator = tf.estimator.Estimator( + model_fn=model_fn, + model_dir=FLAGS.checkpoint_dir, + params=params) + evals = estimator.predict(input_fn=eval_input_fn, yield_single_examples=False) + + # Print error statistics. + all_errors = [x['error'] for x in evals] + errors = np.array(all_errors) + print('Evaluated %d examples'%np.size(errors)) + print('Mean error: %f degrees', np.mean(errors)) + print('Median error: %f degrees', np.median(errors)) + print('Std: %f degrees', np.std(errors)) + sorted_errors = np.sort(errors) + n = np.size(sorted_errors) + print('\nPercentiles:') + for perc in range(1, 101): + index = np.int32(np.float32(n * perc) / 100.0) - 1 + print('%3d%%: %f'%(perc, sorted_errors[index])) + + +def train_and_eval(): + """Train and evaluate a model.""" + # create formatter and add it to the handlers + formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + + # create file handler which logs even debug messages + fh = logging.FileHandler('loss.log') + fh.setLevel(logging.DEBUG) + fh.setFormatter(formatter) + log.addHandler(fh) + + save_summary_steps = FLAGS.save_summaries_steps + save_checkpoints_steps = FLAGS.save_checkpoints_steps + log_step_count = FLAGS.log_step_count + + config = tf.estimator.RunConfig( + save_summary_steps=save_summary_steps, + save_checkpoints_steps=save_checkpoints_steps, + log_step_count_steps=log_step_count, + keep_checkpoint_max=None) + + params = {'dummy': 0} + estimator = tf.estimator.Estimator( + model_fn=model_fn, + model_dir=FLAGS.checkpoint_dir, + config=config, + params=params) + + train_spec = tf.estimator.TrainSpec( + input_fn=train_input_fn, + max_steps=FLAGS.train_steps) + + eval_spec = tf.estimator.EvalSpec(input_fn=eval_input_fn, + start_delay_secs=60, + steps=FLAGS.eval_examples, + throttle_secs=60) + + tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec) + + +def main(argv=None): # pylint: disable=unused-argument + if FLAGS.print_variable_names: + print_variable_names() + return + + if FLAGS.predict_all_test: + predict_all_test() + else: + train_and_eval() + + +if __name__ == '__main__': + tf.app.run() diff --git a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/requirements.txt b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..1f2a5e41d83caa361f20f792da4e4431a8f14bb1 --- /dev/null +++ b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/requirements.txt @@ -0,0 +1,35 @@ +absl-py==0.11.0 +astunparse==1.6.3 +cachetools==4.1.1 +certifi==2020.6.20 +chardet==3.0.4 +gast==0.3.3 +google-auth==1.23.0 +google-auth-oauthlib==0.4.2 +google-pasta==0.2.0 +grpcio==1.33.2 +h5py==2.10.0 +idna==2.10 +importlib-metadata==2.0.0 +Keras-Preprocessing==1.1.2 +Markdown==3.3.3 +numpy==1.18.5 +oauthlib==3.1.0 +opt-einsum==3.3.0 +protobuf==3.13.0 +pyasn1==0.4.8 +pyasn1-modules==0.2.8 +requests==2.24.0 +requests-oauthlib==1.3.0 +rsa==4.6 +scipy==1.5.3 +six==1.15.0 +tensorboard==2.3.0 +tensorboard-plugin-wit==1.7.0 +tensorflow==2.3.1 +tensorflow-estimator==2.3.0 +termcolor==1.1.0 +urllib3==1.25.11 +Werkzeug==1.0.1 +wrapt==1.12.1 +zipp==3.4.0 diff --git a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/utils_gpu.py b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/utils_gpu.py new file mode 100644 index 0000000000000000000000000000000000000000..a08b4fa9700859fdcaede58cc3b4633d302b1156 --- /dev/null +++ b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/utils_gpu.py @@ -0,0 +1,144 @@ +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +# coding=utf-8 +# Copyright 2021 The Google Research Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Utility functions.""" +import numpy as np +from scipy.stats import special_ortho_group +import tensorflow as tf + + +def relative_angle(r1, r2): + """Relative angle (radians) between 3D rotation matrices.""" + rel_rot = tf.matmul(tf.transpose(r1, perm=[0, 2, 1]), r2) + trace = rel_rot[:, 0, 0] + rel_rot[:, 1, 1] + rel_rot[:, 2, 2] + cos_theta = (trace - 1.0) / 2.0 + cos_theta = tf.minimum(cos_theta, tf.ones_like(cos_theta)) + cos_theta = tf.maximum(cos_theta, (-1.0) * tf.ones_like(cos_theta)) + theta = tf.acos(cos_theta) + return theta + + +def random_rotation_benchmark_np(n): + """Sample a random 3D rotation by method used in Zhou et al, CVPR19. + + This numpy function is a copy of the PyTorch function + get_sampled_rotation_matrices_by_axisAngle() in the code made available + for Zhou et al, CVPR19, at https://github.com/papagina/RotationContinuity/. + + Args: + n: the number of rotation matrices to return. + + Returns: + [n, 3, 3] np array. + """ + theta = np.random.uniform(-1, 1, n) * np.pi + sin = np.sin(theta) + axis = np.random.randn(n, 3) + axis = axis / np.maximum(np.linalg.norm(axis, axis=-1, keepdims=True), 1e-7) + qw = np.cos(theta) + qx = axis[:, 0] * sin + qy = axis[:, 1] * sin + qz = axis[:, 2] * sin + + xx = qx*qx + yy = qy*qy + zz = qz*qz + xy = qx*qy + xz = qx*qz + yz = qy*qz + xw = qx*qw + yw = qy*qw + zw = qz*qw + + row0 = np.stack((1-2*yy-2*zz, 2*xy-2*zw, 2*xz+2*yw), axis=-1) + row1 = np.stack((2*xy+2*zw, 1-2*xx-2*zz, 2*yz-2*xw), axis=-1) + row2 = np.stack((2*xz-2*yw, 2*yz+2*xw, 1-2*xx-2*yy), axis=-1) + matrix = np.stack((row0, row1, row2), axis=1) + + return matrix + + +def random_rotation_benchmark(n): + """A TF wrapper for random_rotation_benchmark_np().""" + mat = tf.py_func( + func=lambda t: np.float32(random_rotation_benchmark_np(t)), + inp=[n], + Tout=tf.float32, + stateful=True) + return tf.reshape(mat, (n, 3, 3)) + + +def random_rotation(n): + """Sample rotations from a uniform distribution on SO(3).""" + mat = tf.py_func( + func=lambda t: np.float32(special_ortho_group.rvs(3, size=t)), + inp=[n], + Tout=tf.float32, + stateful=True) + return tf.reshape(mat, (n, 3, 3)) + + +def symmetric_orthogonalization(x): + """Maps 9D input vectors onto SO(3) via symmetric orthogonalization.""" + # Innner dimensions of the input should be 3x3 matrices. + m = tf.reshape(x, (-1, 3, 3)) + _, u, v = tf.svd(m) + det = tf.linalg.det(tf.matmul(u, v, transpose_b=True)) + r = tf.matmul( + tf.concat([u[:, :, :-1], u[:, :, -1:] * tf.reshape(det, [-1, 1, 1])], 2), + v, transpose_b=True) + return r + + +def gs_orthogonalization(p6): + """Gram-Schmidt orthogonalization from 6D input.""" + # Input should be [batch_size, 6] + x = p6[:, 0:3] + y = p6[:, 3:6] + xn = tf.math.l2_normalize(x, axis=-1) + z = tf.linalg.cross(xn, y) + zn = tf.math.l2_normalize(z, axis=-1) + y = tf.linalg.cross(zn, xn) + r = tf.stack([xn, y, zn], -1) + return r diff --git "a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/\350\256\272\346\226\207\347\262\276\345\272\246.jpg" "b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/\350\256\272\346\226\207\347\262\276\345\272\246.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..1f75f76fc00025f29df14a8da23bd8350a0526ed Binary files /dev/null and "b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/GPU/\350\256\272\346\226\207\347\262\276\345\272\246.jpg" differ diff --git a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/README.md b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a4ccebb34585306e0b9a7257a2ecfdb7c08b803f --- /dev/null +++ b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/README.md @@ -0,0 +1,229 @@ +

基本信息

+ +**发布者(Publisher):Huawei** + +**应用领域(Application Domain):CV** + +**版本(Version):** + +**修改时间(Modified) :2022.05.05** + +**框架(Framework):TensorFlow 1.15.0** + +**处理器(Processor):昇腾910** + +**描述(Description):使用训练好的SVD模型,评估对称正交化在点云对准中的应用效果。** + +

概述

+ +给定两个三维点云图,利用SVD正交化过程SVDO+(M)将其投射到SO(3)上,要求网络预测最佳对齐它们的3D旋转。 + +- 开源代码: + + https://github.com/google-research/google-research/tree/master/special_orthogonalization。 + +- 参考论文: + + [An Analysis of SVD for Deep Rotation Estimation](https://arxiv.org/abs/2006.14616) + +- 参考实现: + + obs://cann-id2019/gpu/ + +- 相关迁移的工作: + 在进行代码迁移到NPU上时,输入的训练数据为点云数据,点云数据的shape为(N,3),其中N并不是固定的,因此在NPU上存在动态shape的问题,导致模型训练无法正常进行。我们为此想了三个解决方法:1、找出所有点云数据中最小的N,对于大于N的点云数据,仅取前N行的数据输入训练。2、找到所有点云数据中最大的N,对于小于N的点云进行补0操作,将所有数据固定为最大的N后,输入网络进行训练。3、找到所有点云数据中最大的N,对小于N的点云数据,从原数据中选择一个点云进行填补至行数为N,再将数据输入网络进行训练。该三种方法均成功解决了NPU上的动态shape问题,但是第一种方法删除了样本点,因此导致最后训练出的模型精度很差;第二种方法虽然并没有丢失样本信息,但是向数据中填入大量的0,改变了本来的代码逻辑,导致最后训练出的模型精度也并不高。对于第三种方法,即没有丢失样本信息,对每个点云数据中的某一个点云样本点进行重复操作,没有改变原始的代码逻辑,最后也获得了不错的精度表现。 + +- 通过Git获取对应commit\_id的代码方法如下: + + ``` + git clone {repository_url} # 克隆仓库的代码 + cd {repository_name} # 切换到模型的代码仓目录 + git checkout {branch} # 切换到对应分支 + git reset --hard {commit_id} # 代码设置到对应的commit_id + cd {code_path} # 切换到模型代码所在路径,若仓库下只有该模型,则无需切换 + ``` + +## 默认配置 + +- 数据集获取:obs://cann-id2019/dataset/ + +- 训练超参 + + - log_step_count=200 + - save_summaries_steps=25000 + - train_steps=2600000 + - save_checkpoints_steps=100000 + - eval_examples=39900 + + + +

训练环境准备

+ +1. 硬件环境准备请参见各硬件产品文档"[驱动和固件安装升级指南]( https://support.huawei.com/enterprise/zh/category/ai-computing-platform-pid-1557196528909)"。需要在硬件设备上安装与CANN版本配套的固件与驱动。 +2. 宿主机上需要安装Docker并登录[Ascend Hub中心](https://ascendhub.huawei.com/#/detail?name=ascend-tensorflow-arm)获取镜像。 + + 当前模型支持的镜像列表如[表1](#zh-cn_topic_0000001074498056_table1519011227314)所示。 + + **表 1** 镜像列表 + + + + + + + + + + + + +

镜像名称

+

镜像版本

+

配套CANN版本

+
+

20.2.0

+

20.2

+
+ + + +## 脚本参数 + +``` +gen_pt_test_data_gpu.py 中的参数 + +--input_test_files 传入需要进行旋转的点云数据集 +--output_directory 存储旋转后点云集的路径 +--random_rotation_axang boole型,若为真将会对传入的数据集采用指定方法旋转,默认为真 +--num_rotations_per_file 每个测试点云的随机旋转增加数。默认为100 + + +main_point_cloud_gpu.py 中的参数 + +--pt_cloud_test_files 测试数据集路径 +--pt_cloud_train_files 熟练数据集路径 +--method 指定用于预测旋转的方式。选项为"svd", "svd-inf", or "gs"。默认为“svd” +--checkpoint_dir 训练模型的存放位置 +--train_steps 训练迭代的次数。默认为2600000 +--save_checkpoints_steps 保存检查点的频率。默认为10000 +--log_step_count 日志记录一次的步数。默认为200 +--save_summaries_steps 保存一次summary的步数。默认为5000 +--learning_rate 默认为1e-5 +--lr_decay 如果为真,则衰减learning rate。默认为假 +--lr_decay_steps learning rate衰减步数。默认为35000 +--lr_decay_rate learning rate衰减速率。默认为0.95 +--predict_all_test 如果为真,则在最新的检查点上运行eval作业,并打印每个输入的误差信息。默认为假 +--eval_examples 测试样本的数量。默认为0 +--print_variable_names 打印模型变量名。默认为假 +--num_train_augmentations 增加每个输入点云的随机旋转数。默认为10 + +``` + + + +## 运行 + +GPU运行命令如下: + +**生成测试数据** + +注:生成的文件points_test_modified、points已包含在dataset文件夹中。 +```bash +# 将路径设置到训练点云图文件 +IN_FILES=/shapenet/data/pc_plane/points_test/*.pts + +NEW_TEST_FILES_DIR=/shapenet/data/pc_plane/points_test_modified + +AXANG_SAMPLING=True + +# 决定旋转轴角的分布 +AXANG_SAMPLING=True + +python -m special_orthogonalization.gen_pt_test_data_gpu --input_test_files=$IN_FILES --output_directory=$NEW_TEST_FILES_DIR --random_rotation_axang=$AXANG_SAMPLING +``` + +**训练与评价** +```bash +# 将路径设置到原始训练数据 +TRAIN_FILES=/shapenet/data/pc_plane/points/*.pts + +#将路径设置到旋转后的训练数据 +TEST_FILES=$NEW_TEST_FILES_DIR/*.pts + +# 指定旋转预测方式 +METHOD=svd + +# 指定ckpt、summaries、评价结果等的存储路径 +OUT_DIR=/path/to/model + +python -m special_orthogonalization.main_point_cloud_gpu --method=$METHOD --checkpoint_dir=$OUT_DIR --log_step_count=200 --save_summaries_steps=25000 --pt_cloud_train_files=$TRAIN_FILES --pt_cloud_test_files=$TEST_FILES --train_steps=2600000 --save_checkpoints_steps=100000 --eval_examples=39900 +``` + +**从所有训练样本中生成统计数据** +```bash +# 打印均值、中位数、标准差和分位数 +python -m special_orthogonalization.main_point_cloud_gpu --method=$METHOD --checkpoint_dir=$OUT_DIR --pt_cloud_test_files=$TEST_FILES --predict_all_test=True +``` +## 运行 + +NPU运行命令方式如下: + +对于所有的三个步骤程序来说,modelarts插件obs桶中的数据路径均要写到真正包含数据的那一个路径 +如在pc_plane文件夹中含有points、points_test等包含数据的文件夹 +modelarts插件中的数据路径写为 obs://cann-id2019/data/pc_palne/ + +**生成测试数据** + +运行这一步我们需要的程序文件为gen_pt_test_data.py、modelarts_entry_Axang.py、genTestData.sh +这三个文件中的代码均不需要修改 +最后生成的旋转后的数据文件存放在obs桶当次程序文件的output路径中,文件名为test_points_modified, +为进行第二步模型训练,需要将生成旋转后的文件转移至obs桶中存放data的路径 + +注:需要确保的是存在obs桶里的data文件名为points_test + +**训练与评价** + +运行这一步我们需要的程序文件为main_point_cloud.py、modelarts_entry_acc_train.py、train_full_1p.sh +这三个文件中的代码均不需要修改 +最后生成的旋转后的数据文件存放在obs桶当次程序文件的output路径中,文件名为test_points_modified, +为进行第三步,需要将生成的output文件转移至obs桶中存放data的路径 + +注意:该次训练的模型保存在该次的obs文件夹中,进行第三步时又需要重启一次新的modelarts,因此我们需要将output文件中的 +checkpoint文件中最新模型的路径修改 +"/home/ma-user/modelarts/inputs/data_url_0/output" +这样第三步才能跑出正确的精度指标 + +**从所有训练样本中生成统计数据** + +运行这一步我们需要的程序文件为main_point_cloud.py、modelarts_entry_stat.py、genStatistical.sh +这三个文件的代码均不需要修改 +运行成功后将会在屏幕上打印出关于精度相应的统计量值 + +注意:由于加入了混合精度提高训练性能,导致该步出现未知错误,输出的误差均为0,因此建议将训练后的结果下载到本地 +修改checkpoint文件中模型的路径后,利用本地的GPU进行运行,实际上该步骤在运行时NPU成功启动但也未曾利用。 + +## 训练结果 +**精度对比:** + + + +| 测地线误差(°) | 论文发布 | GPU(初始代码未改动版本) | GPU实测|NPU实测 | +| ------------------------ | ------- | ----- | --------- |----------| +| 平均值 | 1.63 | 2.58 | 3.98 | 2.92 | +| 中值 | 0.89 | 1.68 | 2.6 | 1.7 | +| 标准差 | 6.70 | 6.93 | 9.36 | 8.45 | + +相比于论文中的精度,我们NPU迁移后实测差距依然较大,但是与我们未对代码任何改动初始的版本在GPU上跑出来的精度相差较小, +且对于相同的代码的代码改动,NPU上的精度优于GPU上的精度。需要注意的是,在NPU上运行程序时,我们采用混合精度来提升训练 +的性能,但是其中产生了未知的错误,导致代表的精度指标mean_degree_err在整个训练过程中始终为0,因此我们无法得知在NPU训练的 +260w步的过程中,精度指标是下降的过程是怎样的。值得庆幸的是通过NPU训练出的模型,能够在GPU上计算出精度,并且精度还不错。 + +**性能对比:** + +取弹性云GPU运行的前2600步的global_step/sec平均值和NPU运行的前2600步的global_step/sec平均值进行对比,以达到性能对比的目的。 + +| 性能指标项 | 论文发布 | GPU实测 | NPU实测 | +| ------------------- | ------- | ------ | ------ | +| global_step/sec| 无 | 87.64 | 101.24 | + + diff --git a/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/modelzoo_level.txt b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/modelzoo_level.txt new file mode 100644 index 0000000000000000000000000000000000000000..d648fdf46596d8aae33bc7a5530e1ef8ce7a4bd1 --- /dev/null +++ b/TensorFlow/contrib/cv/SVD_ID2019_for_Tensorflow/modelzoo_level.txt @@ -0,0 +1,3 @@ +FuncStatus:NOK +PerfStatus:NOK +PrecisionStatus:NOK \ No newline at end of file