1

I retrain a mobilenet v2 modell using my own images and i can label new images with the output in python (https://www.tensorflow.org/hub/tutorials/image_retraining). Loading the file works, but during prediction it fails with (concole.log of Firefox and Chromium):

The dict provided in model.execute(dict) has keys: [images] not part of   model graph.

I retrain a modell using the provided retrain.py

python retrain.py --image_dir flower_photos/ --tfhub_module https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2 --random_brightness 10 --how_many_training_steps 100

inside flower_photos there are folders with the name of the images and inside the appropriate images.

flower_photos

--- Huflattich

------- 1.jpg

------- 2.jpg

....

--- Buschwindröschen

------- 1.jpg

------- 2.jpg

I can convert this model using

tensorflowjs_converter --input_format=tf_frozen_model --output_node_names='module_apply_default/MobilenetV2/Logits/output' /tmp/output_graph.pb   Mobilenetv2/web_model

but this isn't working inside the provided example from https://github.com/tensorflow/tfjs-examples/tree/master/mobilenet

If i convert the original mobilenet v2 using

tensorflowjs_converter --input_format=tf_hub 'https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2' mobilenetv2/web_model

i can load inside the provided example.

In the end, the programme should detect different early bloomer flowers shown by the webcam and classify. This should be a PWA for students and motivate them to experience nature.

J. Almer
  • 11
  • 1

1 Answers1

2

Tensorflow.js currently has two types of models,

  1. Layers model which allows training, you can load them with tf.loadModel(...)
  2. Models that are converted from TensorFlow generated models, which does not allow training. This is what you have, you should use tf.loadFrozenModel(...)

here is an example for loading the frozen model and performing a prediction on an image. https://github.com/tensorflow/tfjs-converter/tree/master/demo/mobilenet

serv-inc
  • 35,772
  • 9
  • 166
  • 188
Ping Yu
  • 392
  • 1
  • 3