Package: wai.tfimageclass
Image classification (not object detection) usingtensorflow.Based on example code located here:https://www.tensorflow.org/hub/tutorials/image_retrainingInstallationinstall virtual environment:virtualenv -p /usr/bin/python3.7 venvinstall tensorflow (1.x or 2.x works)with GPU (1.x):./venv/bin/pip install "tensorflow-gpu<2.0.0"with GPU (2.x):./venv/bin/pip install "tensorflow-gpu>=2.0.0"CPU only (1.x):./venv/bin/pip install "tensorflow<2.0.0"CPU only (2.x):./venv/bin/pip install "tensorflow>=2.0.0"install libraryvia pip:./venv/bin/pip install wai.tfimageclassfrom source (from within the directory containing thesetup.pyscript):./venv/bin/pip install .UsageAll scripts support–helpoption to list all available options.TrainFor training, use modulewai.tfimageclass.train.retrainor console scripttfic-retrainFor evaluating a built model, use modulewai.tfimageclass.train.statsor console scripttfic-statsTraining dataAll the data for building the model must be located in a single directory, with each sub-directory representing
alabel. For instance for building a model for distinguishing flowers (daisy, dandelion, roses, sunflowers, tulip),
the data directory looks like this:|
+- flowers
   |
   +- daisy
   |
   +- dandelion
   |
   +- roses
   |
   +- sunflowers
   |
   +- tulipPredictOnce you have built a model, you can use it as follows:For making predictions for a single image, use modulewai.tfimageclass.predict.label_imageor console
scripttfic-labelimageFor polling images in a directory and making continuous predictions with CSV companion files, use
modulewai.tfimageclass.predict.pollor console scripttfic-pollFor making predictions via Redis (https://redis.io/), i.e., broadcasting the image bytes on one
channel and receiving the JSON predictions on another channel, usewai.tfimageclass.predict.label_redisor console scripttfic-label-redisChangelog0.0.15 (2022-05-10)addedwai/tfimageclass/predict/label_redis.pymodule (console script:tfic-label-redis) that
allows making predictions via Redis backend (image bytes in, JSON predictions out).0.0.14 (2021-04-20)added–replace_charsoption toretrain.pyto better manage what characters get replaced with blanks in labels0.0.13 (2021-04-16)added ability tostats.pyto output confusion matrix as well (–output_conf_matrixand–conf_matrix_type)0.0.12 (2021-04-14)poll.pynow handles keyboard interrupts properlystats.pycan use tflite model now as well, using–graph_type tflite0.0.11 (2021-01-26)poll.pycan output predictions now in: csv, xml, jsonlabel_image.pycan output predictions to stdout or a file and in: plaintext (current), csv, xml, json0.0.10 (2021-01-25)removed ability to split images into grid frompoll.pyaddedtfic-exporttool to export saved model folder to Tensorflow lite modeladded support for using tflite models totfic-pollandtfic-labelimage0.0.9 (2020-10-21)poll.pyaccidentally redefined variable for resetting the session.0.0.8 (2020-10-21)poll.pynow re-initializes the Tensorflow session every X processed images to avoid
out of memory problems (–reset_sessionoption).0.0.7 (2020-09-22)poll.pynow outputs the top-X predictions with the correct labels/probability0.0.6 (2020-09-02)poll.pyin non-continuous mode now works as expected (didn’t scan input directory previously)0.0.5 (2020-08-06)label_image.py,poll.pyandstats.pycan now re-use the info JSON file
generated byretrain.pyto simplify command-line parameters (input_height,
input_width, input_layer, output_layer, labels)improved help output of argument parsers: outputting description, command-line
and default values now0.0.4 (2020-08-04)poll.pynow has new–continuousflag to allow for continuous or single batch predictions0.0.3 (2020-07-28)poll.py: added ability to split images into grid of equal sized images, obtaining
a classification for each sub-image.fixed license: now uses Apache 2.0 instead of MIT0.0.2 (2019-11-14)added missingMANIFEST.in0.0.1 (2019-11-01)initial release