C1_W3_assignment Browser-based Models with TensorFlow.js - cannot convert model to json

-i coudntl even get the tensorflowjs_converter tool to work. I have a newbie Q regarding C1_W3_Assignment, section:

Run the TensorFlow.js Converter on The Saved Keras Model

What is this cell in this coursera webpage exactly? Is it like a windows PC command line? Or is it python IDE? and NOT an OS commandline. If it is Python Ide, i would need to use something like subprocess.run() to run this commandline utility from within a python IDE. What is the expectation here? Also, is there new libraries that must be loaded (import os) or pip packages ( pip install pyyaml h5py) that must be installed in order for this to run?

I can save the model, but have tried many times with variations of the following syntax. But it will not run. I think that the version on this coursera webapge may be different to the current keras docs. Whats wrong with this?

tensorflowjs_converter --input_format keras --output_format tfjs_layers_model saved_model_path ./model_js

Also, the video in week3 (converting model to javascript) does extra stuff like generate a subdir using a timestamp. But this is not necessary or even relevant for this exercise, right? And another differernce, the function used for saving the model has 2 parameters:
tf.keras.experimental.export_savedmodel(model,saved_model_path)

Again, this is NOT relevant to the exercise right?

And finally…the video says --input_format keras_saved_model …

But tfjs convertor docs say…(tfjs-converter/tfjs-converter/README.md at master · tensorflow/tfjs-converter · GitHub) …

mentions ‘‘keras’’…instead of ‘‘keras_saved_model’’ (although it provides sample with keras_saved_model) . Which is it? Many thanks in advance :slightly_smiling_face:

and finally finally… This ‘=’ when to use it and when not to use it in the command?
is this correct ?
–input_format=keras_saved_model
or is this correct?
–input_format keras_saved_model

i saw one thing, by mistake after watching it a few times, that change the execution behaviour. In the video he executed with ‘!’ in front of the command (!)

so once i tried !tensorflowjs_converter --input_format=keras_saved_model
etc etc … i got different errors -
2024-12-10 10:12:44.379374: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library ‘libcuda.so.1’; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory

and all of these messages are about cuda cores and stuff not running…

the kernal button seems to only give the option to restart or use python3 - but i am using that already

did you recall first the keras_saved_model with the directory file which contains the h5 model.

the link you shared for conversion to json has the hint.

it is not totally same, and I am suspecting you arent recalling model file with the referenced name

and another thing that i just cannot understand from the github documentation for this utility…

Why doesnt the example have the name of the input model? (ie mymodel.h5 or soemthing like that) And why would it create a subfolder with the ‘unix epoch time’. Other thatn being a way to create a unique subfolder, does this unix epoch time value have any other significance?

What a rabbit hole… :laughing:

thanks for the response Deepti. i cant even get this tool to work on a windows PC from the command line , with absolute directory addresses. If i cant get it working in this simple env, then i cant get it working in the unknown coursera jupyter env. I have downloaded the model. There are piles of warning about numpy versions and deprecated stuff, but only 2 things that look like an actual error. Howver no file is created. How long would it take to create this file? Could it take 1 hour for example?

on my windows 10 pc command prompt (administrator elevation) , the following supersimple line does not work : tensorflowjs_converter --input_format=keras_saved_model c:\week3\my_model.h5 c:\week3\my_json_model

main errors seeem to be…
File “C:\Python312\Lib\site-packages\tensorflowjs\converters\keras_h5_conversion.py”, line 33, in
from tensorflowjs import write_weights # pylint: disable=import-error
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Python312\Lib\site-packages\tensorflowjs\write_weights.py”, line 25, in
from tensorflowjs import read_weights
File “C:\Python312\Lib\site-packages\tensorflowjs\read_weights.py”, line 28, in
np.uint8, np.uint16, np.object, np.bool]

what does success look like? It turns out that a folder was created with shard files. Its just that i only saw this hours later after some form of accidental refresh. Ive no idea what code created it so i will delete it and rerun the latest code line again…

oh. :grimacing: it looks like there is no way to delete this folder…is there a way to delete this folder?

Go through @James comment and the whole thread, it had helped resolve my issue while I did the assignment,