How to load a json model that has a "KerasLayer" in it? #268
-
Hello, I am trying to use the NSFW model (https://github.com/GantMan/nsfw_model) in KotlinDL. I followed the instructions at https://github.com/JetBrains/KotlinDL/blob/master/docs/importing_keras_model.md and was able to save the weights and the json that represents the model. However, the json has a custom "KerasLayer" layer in it whose "handle is "https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/feature_vector/4". In Python, it looks like the way to load that json model is to pass the following to the load_model function:
Is there an equivalent way to do that in KotlinDL to load those json models that have a "KerasLayer" custom layer in them? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @jptarqu thanks for the question. The problem is that KerasLayer is not exactly layer, it's an API abstraction for the trained model saved in special executable format with the unknown structure for KotlinDL, not just simple JSON + weights like other layers The same thing for different Lambda layers which contains Python-specific code |
Beta Was this translation helpful? Give feedback.
Hi @jptarqu thanks for the question.
At this moment you are not able to load KerasLayer (with hidden SavedModel because the SavedModel for 2.x is not supported in KotlinDL yet)
The problem is that KerasLayer is not exactly layer, it's an API abstraction for the trained model saved in special executable format with the unknown structure for KotlinDL, not just simple JSON + weights like other layers
The same thing for different Lambda layers which contains Python-specific code