avishai111
avishai111

Reputation: 11

convert model with tensorflowjs from pb file to json file

I am trying to convert my model (Yolo model) from model.pb to model.json. I trying to do this because I want to load my model directly into my web application (with JavaScript). so I trying to do this with google colab platform and my drive account.

my code:

!pip install -I  Tensorflowjs

%cd /content/gdrive/MyDrive/

!tensorflowjs_converter \
 ./yolov8/saved_model  \
 ./yolov8/yolov8x_web_model

I also check my folders in my google drive account:

the folders in my google drive account

I saw all the files in the right place, but I still get this error:

the error I get in google colab

someone can help, what I am doing wrong ? or maybe another way to load the model directly to my JavaScript code?

I tried many things include to change my code, install the library tensorflowjs again in google colab, and also change my path in the args. but it still doesn't work for me :(

Upvotes: 1

Views: 687

Answers (1)

Abdulmajeed
Abdulmajeed

Reputation: 1535

Double-check that the path to the saved model is correct and that the saved model is located in the directory you specified. You cant try using the tfjs.converters.save_keras_model() function in TensorFlow.js to convert your Yolo model directly to a JSON

model = tf.keras.models.load_model('path/to/yolo/model.h5')

tfjs.converters.save_keras_model(model, 'path/to/output/directory')

Upvotes: 1

Related Questions