How to use the x2paddle.decoder.tf_decoder.TFDecoder function in x2paddle

To help you get started, we’ve selected a few x2paddle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PaddlePaddle / X2Paddle / x2paddle / convert.py View on Github external
if version >= '2.0.0' or version < '1.0.0':
            print(
                "1.0.0<=tensorflow<2.0.0 is required, and v1.14.0 is recommended"
            )
            return
    except:
        print("Tensorflow is not installed, use \"pip install tensorflow\".")
        return

    from x2paddle.decoder.tf_decoder import TFDecoder
    from x2paddle.op_mapper.tf_op_mapper import TFOpMapper
    from x2paddle.op_mapper.tf_op_mapper_nhwc import TFOpMapperNHWC
    from x2paddle.optimizer.tf_optimizer import TFOptimizer

    print("Now translating model from tensorflow to paddle.")
    model = TFDecoder(model_path, define_input_shape=define_input_shape)
    mapper = TFOpMapperNHWC(model)
    optimizer = TFOptimizer(mapper)
    optimizer.delete_redundance_code()
    optimizer.strip_graph()
    #        optimizer.merge_activation()
    #        optimizer.merge_bias()
    mapper.save_inference_model(save_dir, params_merge)