I recently trained a UNet model in Python and saved the model as a Model.h5
file. Following the instructions in the tensorflow JS documentation on How to import a keras model, I used the tensorflowjs_converter
tool to convert the model into a Model.json
file along with several shard files.
My main query now is how to utilize this model in a JavaScript file for image segmentation. I have successfully loaded the model and displayed its summary in the console using the following code:
async function app() {
model = await tf.loadLayersModel(MODEL_JSON_PATH);
model.summary();
}
The model summary displayed in the browser console includes information about different layers and the total parameters of the model.
Now, assuming I have an image on my webpage within an img
tag. How can I input that image into my model and receive the output? I have come across tf.browser.fromPixels
but I am unsure about the next steps. Any assistance or references to relevant examples would be greatly appreciated.