Prepare model:
- Install bazel (check tensorflow's github for more info)
- Prepare folders and files for retraining
- Clone tensorflow
- Go to root of tensorflow
- bazel build tensorflow/examples/image_retraining:retrain
- bazel-bin/tensorflow/examples/image_retraining/retrain --image_dir /path/to/root_folder_name --output_graph /path/output_graph.pb -- output_labels /path/output_labels.txt -- bottleneck_dir /path/bottleneck
** Training done. **
Outputs: output_graph.pb output_labels.txt
Use those outputs in this code as SOURCE_GRAPH and SOURCE_LABELS.
im = ImageMatch(limit=10, source_graph='output_graph.pb', source_labels='output_labels.txt')
from local_settings import SOURCE_GRAPH, SOURCE_LABELS
im = ImageMatch()
im.match('test.jpg')
- test.jpg
- output_labels.txt
- output_graph.pb
Matches:
dandelion (0.9902)
sunflowers (0.0042)
tulips (0.0033)
daisy (0.0014)
roses (0.0009)