コード例 #1
0
    def test_mobilenet_v2(self, quantization_type):
        saved_model_dir = model_coverage.get_filepath(
            "keras_applications/mobilenet_v2_tf2")
        converter = _lite.TFLiteConverterV2.from_saved_model(saved_model_dir)
        img_array = keras.applications.inception_v3.preprocess_input(
            model_coverage.get_image(224))

        self._test_quantization_goldens(quantization_type,
                                        converter,
                                        input_data=[img_array],
                                        golden_name="mobilenet_v2_%s" %
                                        quantization_type.value)
コード例 #2
0
    def test_inception_v3(self, quantization_type):
        keras_model = keras.models.load_model(
            model_coverage.get_filepath("keras_applications/inception_v3.h5"))
        keras_model.inputs[0].set_shape([1, 299, 299, 3])

        converter = _lite.TFLiteConverterV2.from_keras_model(keras_model)
        img_array = keras.applications.inception_v3.preprocess_input(
            model_coverage.get_image(299))

        self._test_quantization_goldens(quantization_type,
                                        converter,
                                        input_data=[img_array],
                                        golden_name="inception_v3_%s" %
                                        quantization_type.value)
コード例 #3
0
    def test_mobilenet_v1(self, quantization_type):
        frozengraph_file = model_coverage.get_filepath(
            "mobilenet/mobilenet_v1_1.0_224_frozen.pb")
        converter = _lite.TFLiteConverter.from_frozen_graph(
            frozengraph_file,
            input_arrays=["input"],
            output_arrays=["MobilenetV1/Predictions/Reshape_1"],
            input_shapes={"input": (1, 224, 224, 3)})
        img_array = keras.applications.inception_v3.preprocess_input(
            model_coverage.get_image(224))

        self._test_quantization_goldens(quantization_type,
                                        converter,
                                        input_data=[img_array],
                                        golden_name="mobilenet_v1_%s" %
                                        quantization_type.value)