Skip to content

tensorflow-hub model to frozen graph #16

@ClarkChin08

Description

@ClarkChin08

Hi lei mao:
Thanks for your blog <<Save, Load and Inference From TensorFlow Frozen Graph>> , that benefits a lot to me as I’m enabling
a style transfer model from tf-hub.
I come across some problems, simply using codes it’s like this:

import tensorflow_hub as hub
hub_handle = 'https://hub.tensorflow.google.cn/google/magenta/arbitrary-image-stylization-v1-256/2’
style_model = hub.load(hub_handle)

The style_model is a saved model: tensorflow.python.saved_model.load.Loader._recreate_base_user_object._UserObject
we can use the style_model to get stylized image prediction:

outputs = style_model(tf.constant(content_image), tf.constant(style_image))

I can also get the signatures as a function to run the model

func = style_model.signatures['serving_default']
outputs = func(tf.constant(content_image), tf.constant(style_image))

Then I try to freeze the func.graph but I come across problems

[op.type for op in func.graph.get_operations()]

The feeds and variables all become Placeholder!

['Placeholder', 'Placeholder', 'Placeholder', 'Placeholder', 'Placeholder’….. 'StatefulPartitionedCall', 'Identity']

Do you know how this happened? Or any solutions about this issue? Many thanks!

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions