是否可以将元数据添加到服务servable
的张量流中,以便该元数据也填充在可服务对象的响应中?
如果我对文件结构有把握:
my_servable/
1541778457/
variables/
saved_model.pb
例如:
```
outputs {
key: "classes"
value {
dtype: DT_STRING
tensor_shape {
dim {
size: 8
}
}
string_val: "a"
string_val: "b"
string_val: "c"
string_val: "d"
string_val: "e"
string_val: "f"
string_val: "g"
string_val: "h"
}
}
outputs {
key: "scores"
value {
dtype: DT_FLOAT
tensor_shape {
dim {
size: 1
}
dim {
size: 8
}
}
float_val: 1.212528104588273e-06
float_val: 5.094948463124638e-08
float_val: 0.0009737954242154956
float_val: 0.9988483190536499
float_val: 3.245145592245535e-07
float_val: 0.00010837535955943167
float_val: 4.101086960872635e-05
float_val: 2.676981057447847e-05
}
}
model_spec {
name: "my_model"
version {
value: 1541778457
}
signature_name: "prediction"
}
如果对于生成此可服务项的代码(例如f6ca434910504532a0d50dfd12f22d4c
)来说,我有类似git哈希或唯一标识符的代码,是否可以在客户端请求中获取此数据?
理想情况是:
```
outputs {
key: "classes"
value {
dtype: DT_STRING
tensor_shape {
dim {
size: 8
}
}
string_val: "a"
string_val: "b"
string_val: "c"
string_val: "d"
string_val: "e"
string_val: "f"
string_val: "g"
string_val: "h"
}
}
outputs {
key: "scores"
value {
dtype: DT_FLOAT
tensor_shape {
dim {
size: 1
}
dim {
size: 8
}
}
float_val: 1.212528104588273e-06
float_val: 5.094948463124638e-08
float_val: 0.0009737954242154956
float_val: 0.9988483190536499
float_val: 3.245145592245535e-07
float_val: 0.00010837535955943167
float_val: 4.101086960872635e-05
float_val: 2.676981057447847e-05
}
}
model_spec {
name: "my_model"
version {
value: 1541778457
}
hash {
value: f6ca434910504532a0d50dfd12f22d4c
}
signature_name: "prediction"
}
我尝试将目录从1541778457
更改为哈希,但这给出了:
W tensorflow_serving/sources/storage_path/file_system_storage_path_source.cc:268] No versions of servable default found under base path
答案 0 :(得分:0)
我想您可以通过两种方式解决此问题。如果您想更改文件夹名称以使其正常工作,请记住在这种情况下,该文件夹名称描述您的模型版本,我认为该版本必须为整数。因此,我假设您需要将哈希转换为二进制或十进制,然后在收到时将其转换回。
我认为,更好的解决方案是您是否能够更改模型并添加包含哈希的变量。并将其添加到模型signature_def。在python中看起来像:
// create your field
hash = tf.placeholder("f6ca434910504532a0d50dfd12f22d4c",tf.string, name="HASH")
// build tensor
hash_info = tf.saved_model.utils.build_tensor_info(hash)
// add hash_info in your output in signature_def
// then you should be able to receive that data in your request