You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

module_v2.cs 1.2 kB

123456789101112131415161718192021222324252627282930313233
  1. using System.IO;
  2. using Tensorflow.Train;
  3. namespace Tensorflow.Hub
  4. {
  5. internal static class module_v2
  6. {
  7. public static Trackable load(string handle, LoadOptions? options)
  8. {
  9. var module_path = resolve(handle);
  10. // TODO(Rinne): deal with is_hub_module_v1
  11. var saved_model_path = Path.Combine(module_path, Constants.SAVED_MODEL_FILENAME_PB);
  12. var saved_model_pb_txt_path = Path.Combine(module_path, Constants.SAVED_MODEL_FILENAME_PBTXT);
  13. if (!File.Exists(saved_model_path) && !Directory.Exists(saved_model_path) && !File.Exists(saved_model_pb_txt_path)
  14. && !Directory.Exists(saved_model_pb_txt_path))
  15. {
  16. throw new ValueError($"Trying to load a model of incompatible/unknown type. " +
  17. $"'{module_path}' contains neither '{Constants.SAVED_MODEL_FILENAME_PB}' " +
  18. $"nor '{Constants.SAVED_MODEL_FILENAME_PBTXT}'.");
  19. }
  20. var obj = Loader.load(module_path, options: options);
  21. return obj;
  22. }
  23. public static string resolve(string handle)
  24. {
  25. return MultiImplRegister.GetResolverRegister().Call(handle);
  26. }
  27. }
  28. }