Image classification using tensorflow.
Project description
Image classification (not object detection) using tensorflow.
Based on example code located here:
https://www.tensorflow.org/hub/tutorials/image_retraining
Installation
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"
install library
via pip:
./venv/bin/pip install wai.tfimageclass
from source (from within the directory containing the setup.py script):
./venv/bin/pip install .
Usage
All scripts support –help option to list all available options.
Train
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
Training data
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
Predict
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
Changelog
0.0.7 (2020-09-22)
poll.py now outputs the top-X predictions with the correct labels/probability
0.0.6 (2020-09-02)
poll.py in non-continuous mode now works as expected (didn’t scan input directory previously)
0.0.5 (2020-08-06)
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
0.0.4 (2020-08-04)
poll.py now has new –continuous flag to allow for continuous or single batch predictions
0.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 MIT
0.0.2 (2019-11-14)
added missing MANIFEST.in
0.0.1 (2019-11-01)
initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file wai.tfimageclass-0.0.7.tar.gz
.
File metadata
- Download URL: wai.tfimageclass-0.0.7.tar.gz
- Upload date:
- Size: 29.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c36a00b52dc1fbec926ef0d96c32693ad2c1a16cd30c4afacbd9da2d72d2e933 |
|
MD5 | 6039df4bb1550435434cc1c075060e20 |
|
BLAKE2b-256 | 63eea74eb45932dd971b0f06f372be4f32e2a969736a6ca9833d2d305df6f67c |