@@ -0,0 +1,1698 @@
+#%0A# Copyright 2018 Analytics Zoo Authors.%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A#%0A%0Aimport os%0Aimport pytest%0A%0Afrom unittest import TestCase%0Afrom zoo.pipeline.inference import InferenceModel%0A%0Afrom zoo.pipeline.api.torch import zoo_pickle_module%0Aimport torch%0Aimport torchvision%0Afrom zoo.common.nncontext import *%0A%0A%0Aclass TestInferenceModelTorch(TestCase):%0A%0A    def setUp(self):%0A        %22%22%22 setup any state tied to the execution of the given method in a%0A        class.  setup_method is invoked for every test method of a class.%0A        %22%22%22%0A        self.sc = init_spark_on_local(4)%0A%0A    def tearDown(self):%0A        %22%22%22 teardown any state that was previously setup with a setup_method%0A        call.%0A        %22%22%22%0A        self.sc.stop()%0A%0A    def test_load_torch(self):%0A        torch_model = torchvision.models.resnet18()%0A        tmp_path = create_tmp_path() + %22.pt%22%0A        torch.save(torch_model, tmp_path, pickle_module=zoo_pickle_module)%0A        model = InferenceModel(10)%0A        model.load_torch(tmp_path)%0A        input_data = np.random.random(%5B4, 3, 224, 224%5D)%0A        output_data = model.predict(input_data)%0A        os.remove(tmp_path)%0A%0A%0Aif __name__ == %22__main__%22:%0A    pytest.main(%5B__file__%5D)%0A

Add Inference Model PythonAPI (#3038)