Update look extension with custom models

Hi,
I would like to update Look Extenxion with my own model files.
I retrain mobilenet model on my custom dataset according to tensorflow-for-poets-2 repo.

My tensorflow version is 1.15.0

The main commonds are below.

python -m scripts.retrain ^
 --bottleneck_dir=./caoshu_bottlenecks ^ 
--how_many_training_steps=4000 ^ 
--model_dir=tf_files/models/ ^ 
--summaries_dir=tf_files/training_summaries/"mobilenet_1.0_224" ^ 
--output_graph=tf_files/caoshu_graph.pb ^ 
--output_labels=tf_files/caoshu_labels.txt ^ 
--architecture="mobilenet_1.0_224" ^ 
--image_dir=./caoshu_imgs 


python scripts/quantize_graph.py ^ 
--input=tf_files/caoshu_graph.pb ^ 
--output=tf_files/quantized_graph.pb ^ 
--output_node_names=final_result ^ 
--mode=weights_rounded 

tensorflowjs_converter ^ 
--input_format=tf_frozen_model ^ 
--output_node_names=final_result ^ 
--output_format=tfjs_graph_model ^ 
tf_files/quantized_graph.pb ^ 
tf_files/for_web

finally it give me files in the for_web folder as below,
tensorflowjs_converter version is 1.3.2

group1-shard1of5.bin
 group1-shard2of5.bin
 group1-shard3of5.bin
 group1-shard4of5.bin
 group1-shard5of5.bin
 model.json (I rename it to weights_manifest.json later)

I replace the existing model with the new model and update the list of files in the @UsesAssets annotation in Look.java, ant extensions with no errors.

files in assets floder

group1-shard1of5.bin
group1-shard2of5.bin
group1-shard3of5.bin
group1-shard4of5.bin
group1-shard5of5.bin
weights_manifest.json ( replace the original file with my own as above)
tfjs-0.12.4.js
scavenger_classes.js  (modify the classes according to  my lable file )
look.js

I modify Look.java as below

@UsesAssets(fileNames = "look.html, look.js, group1-shard1of5.bin,group1-shard2of5.bin,group1-shard3of5.bin,group1-shard4of5.bin,group1-shard5of5.bin, weights_manifest.json, scavenger_classes.js, tfjs-0.12.4.js")

But the AI 2 App classification does not work,the APP screen just show white.

What is the problem?Thanks.

BR
Tom

1 Like

What are the contents of your weights_manifest.json?

My weights_manifest.json is here.