Image classification using tensorflow.
Image classification (not object detection) using tensorflow.
Based on example code located here:
install virtual environment:
virtualenv -p /usr/bin/python3.7 venv
install 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"
./venv/bin/pip install wai.tfimageclass
from source (from within the directory containing the setup.py script):
./venv/bin/pip install .
All scripts support –help option to list all available options.
- For training, use module wai.tfimageclass.train.retrain or console script tfic-retrain
- For evaluating a built model, use module wai.tfimageclass.train.stats or console script tfic-stats
All the data for building the model must be located in a single directory, with each sub-directory representing a label. 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 | +- tulip
Once you have built a model, you can use it as follows:
- For making predictions for a single image, use module wai.tfimageclass.predict.label_image or console script tfic-labelimage
- For polling images in a directory and making continous predictions with CSV companion files, use module wai.tfimageclass.predict.poll or console script tfic-poll
- added –replace_chars option to retrain.py to better manage what characters get replaced with blanks in labels
- added ability to stats.py to output confusion matrix as well (–output_conf_matrix and –conf_matrix_type)
- poll.py now handles keyboard interrupts properly
- stats.py can use tflite model now as well, using –graph_type tflite
- poll.py can output predictions now in: csv, xml, json
- label_image.py can output predictions to stdout or a file and in: plaintext (current), csv, xml, json
- removed ability to split images into grid from poll.py
- added tfic-export tool to export saved model folder to Tensorflow lite model
- added support for using tflite models to tfic-poll and tfic-labelimage
- poll.py accidentally redefined variable for resetting the session.
- poll.py now re-initializes the Tensorflow session every X processed images to avoid out of memory problems (–reset_session option).
- poll.py now outputs the top-X predictions with the correct labels/probability
- poll.py in non-continuous mode now works as expected (didn’t scan input directory previously)
- label_image.py, poll.py and stats.py can now re-use the info JSON file generated by retrain.py to 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 now
- poll.py now has new –continuous flag to allow for continuous or single batch predictions
- 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 MIT
- added missing MANIFEST.in
- initial release
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size wai.tfimageclass-0.0.14.tar.gz (33.1 kB)||File type Source||Python version None||Upload date||Hashes View|