Created
November 28, 2018 06:37
-
-
Save ColeMurray/a9d3435563c9c8fcf893058661f2847f to your computer and use it in GitHub Desktop.
Predict script for age gender estimation tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from argparse import ArgumentParser | |
import tensorflow as tf | |
from scipy.misc import imread | |
from tensorflow.contrib import predictor | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger(__name__) | |
tf.logging.set_verbosity(tf.logging.INFO) | |
if __name__ == '__main__': | |
parser = ArgumentParser(add_help=True) | |
parser.add_argument('--model-dir', required=True) | |
parser.add_argument('--image-path', required=True) | |
args = parser.parse_args() | |
prediction_fn = predictor.from_saved_model(export_dir=args.model_dir, signature_def_key='serving_default') | |
batch = [] | |
image = imread(args.image_path) | |
output = prediction_fn({ | |
'image': [image] | |
}) | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment