# Error while importing efficientnet lite0 model

**URL:** <https://discuss.ai.google.dev/t/error-while-importing-efficientnet-lite0-model/29042>\
**Category:** General Discussion\
**Tags:** tfjs\
**Created:** [November 2, 2021, 2:39am UTC](https://discuss.ai.google.dev/t/error-while-importing-efficientnet-lite0-model/29042 "2021-11-02T02:39:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rolo](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/rolo/32/9444_2.png) [@rolo](https://discuss.ai.google.dev/u/rolo)\
**Post date:** [November 2, 2021, 2:39am UTC](https://discuss.ai.google.dev/t/error-while-importing-efficientnet-lite0-model/29042/1 "2021-11-02T02:39:37Z")

</div>

I have trained a model using tensorflow model maker

```
model = image_classifier.create(
    train_data, 
    train_whole_model= False,
    epoch=5
)

```

and exporting it:

`model.export(export_dir='./tfjs-model', export_format=ExportFormat.TFJS)`

then with tensorflow js I load it:

model = await tf.loadLayersModel(“./tfjs-model/model.json”);

but it throws the following error

```
Unknown layer: HubKerasLayerV1V2. This may be due to one of the following reasons:
1. The layer is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
2. The custom layer is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().
    at deserializeKerasObject (generic_utils.js:227)
    at deserialize (serialization.js:25)
    at fromConfig (models.js:861)
    at deserializeKerasObject (generic_utils.js:258)
    at deserialize (serialization.js:25)
    at loadLayersModelFromIOHandler (models.js:222)

```

I have also tried to export the model with tensorflow js, but I get the same error

`tensorflowjs\_converter --input\_format=tf\_saved\_model --output\_node\_names=‘efficientnet-b0/model/blocks\_1/tpu\_match\_normalization’ --saved\_model\_tags=./model ./tfjs-model2

---

<div class="post-metadata">

**Author:** ![Shivam\_Mishra](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/shivam_mishra/32/14113_2.png) [@Shivam\_Mishra](https://discuss.ai.google.dev/u/Shivam_Mishra)\
**Post date:** [September 13, 2024, 10:09am UTC](https://discuss.ai.google.dev/t/error-while-importing-efficientnet-lite0-model/29042/3 "2024-09-13T10:09:19Z")

</div>

Hi @rolo ,

I **Apologies** for the late response. It’s a known issue in _ **tfjs-converter** _ where custom layers created by **TensorFlow or Keras** can’t be converted to TensorFlow.js models.

The workaround for this issue is to load your model as a **Graph model** instead of a **Layer model**.

You can convert your model to a Graph model using the following command:

`tensorflowjs_converter --input_format keras --output_format=tfjs_graph_model keras-h5 model.json`

Use this command to load the model:

`const model = tf.loadGraphModel('/model/model.json')`.

Let me know, if it works for you.

Thank You!!

---

<div class="post-metadata">

**Author:** ![Shivam\_Mishra](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/shivam_mishra/32/14113_2.png) [@Shivam\_Mishra](https://discuss.ai.google.dev/u/Shivam_Mishra)\
**Post date:** [December 2, 2024, 7:47pm UTC](https://discuss.ai.google.dev/t/error-while-importing-efficientnet-lite0-model/29042/5 "2024-12-02T19:47:36Z")

</div>

Hi @rolo ,

I apologize for the late response. The `custom layer` that you are creating needs to be registered with the `serialization` map of `TFJS` so that it can be serialized and deserialized.

This example might help you resolve your issue:

```auto
import * as tf from '@tensorflow/tfjs';
// Assuming your custom layer class is named 'MyCustomLayer'
tf.serialization.registerClass(MyCustomLayer);
const model = await tf.loadLayersModel('your_model.json');

```

Let me know if this helps. Thank you!
