frozen_graphs_to_uffs.py 834 B

123456789101112131415161718192021222324252627
  1. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
  2. # Full license terms provided in LICENSE.md file.
  3. import sys
  4. sys.path.append('third_party/models/')
  5. sys.path.append('third_party/models/research')
  6. sys.path.append('third_party/models/research/slim')
  7. import uff
  8. from model_meta import NETS, FROZEN_GRAPHS_DIR, CHECKPOINT_DIR, UFF_DIR
  9. if __name__ == '__main__':
  10. for net_name, net_meta in NETS.items():
  11. if 'exclude' in net_meta.keys() and net_meta['exclude'] is True:
  12. continue
  13. print("Convertings %s to UFF" % net_name)
  14. uff_model = uff.from_tensorflow_frozen_model(
  15. frozen_file=net_meta['frozen_graph_filename'],
  16. output_nodes=net_meta['output_names'],
  17. output_filename=net_meta['uff_filename'],
  18. text=False
  19. )