提交 55db5c62 编写于 作者: M MRXLT

use local model

上级 76a8cc2b
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
__version__ = '0.1.4' __version__ = '0.1.6'
...@@ -63,6 +63,9 @@ class PLSCServer(): ...@@ -63,6 +63,9 @@ class PLSCServer():
def modify_conf(self, gpu_index=0): def modify_conf(self, gpu_index=0):
os.chdir(self.get_path()) os.chdir(self.get_path())
engine_name = 'name: "face_resnet50"' engine_name = 'name: "face_resnet50"'
if self.model_path_str == '':
print('Please set model path using with_model.')
return -1
if not self.with_gpu_flag: if not self.with_gpu_flag:
with open('./conf/model_toolkit.prototxt', 'r') as f: with open('./conf/model_toolkit.prototxt', 'r') as f:
conf_str = f.read() conf_str = f.read()
...@@ -86,6 +89,8 @@ class PLSCServer(): ...@@ -86,6 +89,8 @@ class PLSCServer():
'enable_memory_optimization: 1', conf_str) 'enable_memory_optimization: 1', conf_str)
open(conf_file, 'w').write(conf_str) open(conf_file, 'w').write(conf_str)
return 0
def hold(self): def hold(self):
try: try:
while True: while True:
...@@ -99,6 +104,10 @@ class PLSCServer(): ...@@ -99,6 +104,10 @@ class PLSCServer():
os.chdir(self.get_path()) os.chdir(self.get_path())
self.modify_conf(gpu_index) self.modify_conf(gpu_index)
if self.modify_conf(gpu_index) != 0:
print('Modify conf files failed')
return -1
if self.with_gpu_flag == True: if self.with_gpu_flag == True:
gpu_msg = '--gpuid=' + str(gpu_index) + ' ' gpu_msg = '--gpuid=' + str(gpu_index) + ' '
run_cmd = self.gpu_run_cmd + gpu_msg run_cmd = self.gpu_run_cmd + gpu_msg
...@@ -150,16 +159,13 @@ class PLSCServer(): ...@@ -150,16 +159,13 @@ class PLSCServer():
print(conf_str) print(conf_str)
''' '''
def with_model(self, model_name=None, model_url=None): def with_model(self, model_path=None):
''' if not (os.path.isabs(model_path) and os.path.exists(model_path)):
if model_url != None: print('Please set correct absolute path for model file')
self.mode_url = model_url return -1
self.use_other_model = True
''' self.model_path_str = r'model_data_path: "' + model_path + r'"'
if model_name == None or type(model_name) != str:
print('Please set model name string')
os.chdir(self.get_path()) os.chdir(self.get_path())
self.get_model(model_name)
def get_path(self): def get_path(self):
py_path = os.path.dirname(plsc_serving.__file__) py_path = os.path.dirname(plsc_serving.__file__)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册