tensorflow / tensorflow/tensorboard
example.tfrecords not displaying on What-If dashboard
@jameswex is already working on this.
Since Nov 1, 2018.
- Dominant language
- TypeScript
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 1
Description
I've converted a keras model into tensorflow saved model using saved_model_builder.SavedModelBuilder(export_path)
to be able to use is on whatif.
I've started a serving docker container docker run -p 8500:8500 --mount type=bind,source=/var/www/whatif_testing/model_name,target=/models/model_name -e MODEL_NAME=model_name -t tensorflow/serving
JPEG image data is converted into serialized tfrecords file using the below code.
def convert_to_record(train_addrs, train_labels, destination, keyword="train"):
# address to save the TFRecords file
train_filename = os.path.join(destination, keyword+'.tfrecords')
# open the TFRecords file
writer = tf.python_io.TFRecordWriter(train_filename)
for i in range(len(train_addrs)):
# print how many images are saved every 1000 images
if not i % 10:
sys.stdout.write(
'{} data: {}/{}\r'.format(keyword, i, len(train_addrs)))
sys.stdout.flush()
# Load the image
img = cv2.imread(train_addrs[i])
img = cv2.resize(img, shape, interpolation=cv2.INTER_CUBIC)
img = img.astype(np.uint8)/255.0
label = train_labels[i]
# Create a feature
feature = {keyword+'/label': tf.train.Feature(int64_list=tf.train.Int64List(value=[label])),
keyword+'/image': tf.train.Feature(bytes_list=tf.train.BytesList(value=[tf.compat.as_bytes(img.tostring())])) }
# Create an example protocol buffer
example = tf.train.Example(features=tf.train.Features(feature=feature))
# Serialize to string and write on the file
writer.write(example.SerializeToString())
writer.close()
sys.stdout.flush()
This leads to an error from the model server
status = StatusCode.INVALID_ARGUMENT
details = "Expects arg[0] to be double but string is provided"
debug_error_string = "{"created":"@1541100531.185075510",
"description":"Error received from peer",
"file":"src/core/lib/surface/call.cc",
"file_line":1017,
"grpc_message":"Expects arg[0] to be double but string is provided",
"grpc_status":3}"
I'm trying to understand what is the correct format of input image, input label and signature_def_map of the model
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.