-
Notifications
You must be signed in to change notification settings - Fork 4
/
export_serving_model.py
60 lines (46 loc) · 1.91 KB
/
export_serving_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# coding: utf-8
# author: [email protected]
r'''Export hyaudio model to TensorFlow Serving.'''
from saved_model import ServingInfo
from saved_model import export_serving_model
from saved_model import check_model_version_from_file
########### messages ###########
UPDATE_MESSAGE = 'add hyaudio_1 and hyaudio_2 model' # need be specified
########### export info ###########
@ServingInfo.export
def audio_hyaudio():
signature_name = 'hyaudio_1'
frozen_pb = 'audio/hyaudio.pb'
input_signature_map = { 'inputs':'hyaudio/vggish_input:0' }
output_signature_map = { 'classes':'hyaudio/predict_classes:0',
'probs':'hyaudio/predict_probs:0'}
return ServingInfo(frozen_pb, input_signature_map,
output_signature_map, signature_name)
@ServingInfo.export
def audio_hyaudio():
signature_name = 'hyaudio_2'
frozen_pb = 'audio/hyaudio.pb'
input_signature_map = { 'inputs':'hyaudio/vggish_input:0' }
output_signature_map = { 'classes':'hyaudio/predict_classes:0',
'probs':'hyaudio/predict_probs:0'}
return ServingInfo(frozen_pb, input_signature_map,
output_signature_map, signature_name)
# Will not export
# @ServingInfo.export
def audio_hyaudio():
signature_name = 'hyaudio_3'
frozen_pb = 'audio/hyaudio.pb'
input_signature_map = { 'inputs':'hyaudio/vggish_input:0' }
output_signature_map = { 'classes':'hyaudio/predict_classes:0',
'probs':'hyaudio/predict_probs:0'}
return ServingInfo(frozen_pb, input_signature_map,
output_signature_map, signature_name)
if __name__ == '__main__':
_EXPORT_DIR = r'./serving'
_FROZEN_DIR = r'./frozen'
_MODEL_VERSION = check_model_version_from_file(
_EXPORT_DIR,
update_message=UPDATE_MESSAGE,
verbose=True)
export_serving_model(_FROZEN_DIR, _EXPORT_DIR, _MODEL_VERSION,
show_all_models=True, show_all_tensors=True)