Docker打包上传多个训练好的模型
模型文件路径设置
pbmodel
├─model1
├─0
├─variables
├─saved_model.pb
├─model2
├─0
├─variables
├─saved_model.pb
└models.config
docker脚本设置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #!/bin/bash # keras2tensorflow test.py
base_repo_name='tensorflow/serving' #基础镜像 base_repo_tag='latest' hub_repo_name='hub.xxx.xx/xxx/video_blurred_model_base' hub_repo_tag='v0.1' commit_msg='添加花屏检测模型'
#container_id=`docker run -itd -p 8501:8501 ${base_repo_name}':'${base_repo_tag} --model_config_file=/models/models.config /bin/bash` container_id=`docker run -itd -p 8501:8501 ${base_repo_name}':'${base_repo_tag} /bin/bash` echo "container_id is : " echo $container_id docker cp /Users/zzy/PycharmProjects/video-parsing-models/pbmodel/models.config $container_id:/models docker cp /Users/zzy/PycharmProjects/video-parsing-models/pbmodel/blurred_screen_model $container_id:/models sha_image_id=`docker commit -m ${commit_msg} ${container_id}` echo ${sha_image_id} image_id=(${sha_image_id//sha256:/}) #需要将返回的sha256:image_id进行过滤 docker tag ${image_id} ${hub_repo_name}':'${hub_repo_tag} docker push ${hub_repo_name}':'${hub_repo_tag} docker restart ${container_id}
|
models.config文件设置
1 2 3 4 5 6 7 8 9 10 11 12
| model_config_list { config { name: 'blurred_screen_model' base_path: '/models/blurred_screen_model' model_platform: 'tensorflow' } config { name: 'blurred_screen_model2' base_path: '/models/blurred_screen_model2' model_platform: 'tensorflow' } }
|