File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
tensorflow-core/tensorflow-core-api/src Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,25 @@ public void export() throws IOException {
312
312
private final Map <String , SessionFunction > functions = new LinkedHashMap <>();
313
313
}
314
314
315
+ /**
316
+ * Load a saved model from an export directory. The model that is being loaded should be created
317
+ * using the <a href="https://www.tensorflow.org/api_docs/python/tf/saved_model">Saved Model
318
+ * API</a>.
319
+ *
320
+ * <p>This method is a shorthand for:
321
+ *
322
+ * <pre>{@code
323
+ * SavedModelBundle.loader().load();
324
+ * }</pre>
325
+ *
326
+ * @param exportDir the directory path containing a saved model.
327
+ * @return a bundle containing the graph and associated session.
328
+ */
329
+ public static SavedModelBundle load (String exportDir ) {
330
+ Loader loader = loader (exportDir );
331
+ return loader .load ();
332
+ }
333
+
315
334
/**
316
335
* Load a saved model from an export directory. The model that is being loaded should be created
317
336
* using the <a href="https://www.tensorflow.org/api_docs/python/tf/saved_model">Saved Model
@@ -329,9 +348,7 @@ public void export() throws IOException {
329
348
*/
330
349
public static SavedModelBundle load (String exportDir , String ... tags ) {
331
350
Loader loader = loader (exportDir );
332
- if (tags != null && tags .length > 0 ) {
333
- loader .withTags (tags );
334
- }
351
+ loader .withTags (tags );
335
352
return loader .load ();
336
353
}
337
354
Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ public class SavedModelBundleTest {
68
68
69
69
@ Test
70
70
public void load () {
71
+ try (SavedModelBundle bundle = SavedModelBundle .load (SAVED_MODEL_PATH )) {
72
+ assertNotNull (bundle .session ());
73
+ assertNotNull (bundle .graph ());
74
+ assertNotNull (bundle .metaGraphDef ());
75
+ }
71
76
try (SavedModelBundle bundle = SavedModelBundle .load (SAVED_MODEL_PATH , "serve" )) {
72
77
assertNotNull (bundle .session ());
73
78
assertNotNull (bundle .graph ());
You can’t perform that action at this time.
0 commit comments