How to use tfserver - 2 common examples

To help you get started, we’ve selected a few tfserver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github visipedia / tf_classification / tfserving / client.py View on Github external
def main():

  args = parse_args()

  # Read in the image bytes
  image_data = []
  for fp in args.image_paths:
    with open(fp) as f:
      data = f.read()
    image_data.append(data)

  # Get the predictions
  t = time.time()
  predictions = tfserver.predict(image_data, model_name=args.model_name,
    host=args.host, port=args.port, timeout=args.timeout
  )
  dt = time.time() - t
  print("Prediction call took %0.4f seconds" % (dt,))

  # Process the results
  results = tfserver.process_classification_prediction(predictions, max_classes=args.num_results)

  # Print the results
  for i, fp in enumerate(args.image_paths):
    print("Results for image: %s" % (fp,))
    for name, score in results[i]:
      print("%s: %0.3f" % (name, score))
    print()
github visipedia / tf_classification / tfserving / client.py View on Github external
image_data = []
  for fp in args.image_paths:
    with open(fp) as f:
      data = f.read()
    image_data.append(data)

  # Get the predictions
  t = time.time()
  predictions = tfserver.predict(image_data, model_name=args.model_name,
    host=args.host, port=args.port, timeout=args.timeout
  )
  dt = time.time() - t
  print("Prediction call took %0.4f seconds" % (dt,))

  # Process the results
  results = tfserver.process_classification_prediction(predictions, max_classes=args.num_results)

  # Print the results
  for i, fp in enumerate(args.image_paths):
    print("Results for image: %s" % (fp,))
    for name, score in results[i]:
      print("%s: %0.3f" % (name, score))
    print()

tfserver

Tensor Flow Model Server

Apache-2.0
Latest version published 5 months ago

Package Health Score

78 / 100
Full package analysis

Similar packages