未验证 提交 1ba9b4c2 编写于 作者: C chenjian 提交者: GitHub

fix a bug for string format (#1199)

Co-authored-by: Nheliqi <1101791222@qq.com>
上级 acd6c6df
...@@ -307,8 +307,8 @@ class HttpClientManager: ...@@ -307,8 +307,8 @@ class HttpClientManager:
return fastdeploy_client return fastdeploy_client
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
'Can not connect to server {}, please check your \ 'Can not connect to server {}, please check your '
server address'.format(server_url)) 'server address'.format(server_url))
def infer(self, server_url, model_name, model_version, inputs): def infer(self, server_url, model_name, model_version, inputs):
fastdeploy_client = self._create_client(server_url) fastdeploy_client = self._create_client(server_url)
......
...@@ -27,8 +27,8 @@ def visualize_detection(image, data): ...@@ -27,8 +27,8 @@ def visualize_detection(image, data):
import fastdeploy as fd import fastdeploy as fd
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
"fastdeploy is required for visualizing results,please refer to \ "fastdeploy is required for visualizing results,please refer to "
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy") "https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
boxes = np.array(data['boxes']) boxes = np.array(data['boxes'])
scores = np.array(data['scores']) scores = np.array(data['scores'])
label_ids = np.array(data['label_ids']) label_ids = np.array(data['label_ids'])
...@@ -49,8 +49,8 @@ def visualize_keypoint_detection(image, data): ...@@ -49,8 +49,8 @@ def visualize_keypoint_detection(image, data):
import fastdeploy as fd import fastdeploy as fd
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
"fastdeploy is required for visualizing results,please refer to \ "fastdeploy is required for visualizing results,please refer to "
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy") "https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
keypoints = np.array(data['keypoints']) keypoints = np.array(data['keypoints'])
scores = np.array(data['scores']) scores = np.array(data['scores'])
num_joints = np.array(data['num_joints']) num_joints = np.array(data['num_joints'])
...@@ -69,8 +69,8 @@ def visualize_face_detection(image, data): ...@@ -69,8 +69,8 @@ def visualize_face_detection(image, data):
import fastdeploy as fd import fastdeploy as fd
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
"fastdeploy is required for visualizing results,please refer to \ "fastdeploy is required for visualizing results,please refer to "
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy") "https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
data = np.array(data['data']) data = np.array(data['data'])
scores = np.array(data['scores']) scores = np.array(data['scores'])
landmarks = np.array(data['landmarks']) landmarks = np.array(data['landmarks'])
...@@ -91,8 +91,8 @@ def visualize_face_alignment(image, data): ...@@ -91,8 +91,8 @@ def visualize_face_alignment(image, data):
import fastdeploy as fd import fastdeploy as fd
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
"fastdeploy is required for visualizing results,please refer to \ "fastdeploy is required for visualizing results,please refer to "
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy") "https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
landmarks = np.array(data['landmarks']) landmarks = np.array(data['landmarks'])
facealignment_result = fd.C.vision.FaceAlignmentResult() facealignment_result = fd.C.vision.FaceAlignmentResult()
...@@ -107,8 +107,8 @@ def visualize_segmentation(image, data): ...@@ -107,8 +107,8 @@ def visualize_segmentation(image, data):
import fastdeploy as fd import fastdeploy as fd
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
"fastdeploy is required for visualizing results,please refer to \ "fastdeploy is required for visualizing results,please refer to "
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy") "https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
label_ids = np.array(data['label_ids']) label_ids = np.array(data['label_ids'])
score_map = np.array(data['score_map']) score_map = np.array(data['score_map'])
shape = np.array(data['shape']) shape = np.array(data['shape'])
...@@ -127,8 +127,8 @@ def visualize_matting(image, data): ...@@ -127,8 +127,8 @@ def visualize_matting(image, data):
import fastdeploy as fd import fastdeploy as fd
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
"fastdeploy is required for visualizing results,please refer to \ "fastdeploy is required for visualizing results,please refer to "
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy") "https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
alpha = np.array(data['alpha']) alpha = np.array(data['alpha'])
foreground = np.array(data['foreground']) foreground = np.array(data['foreground'])
contain_foreground = data['contain_foreground'] contain_foreground = data['contain_foreground']
...@@ -149,8 +149,8 @@ def visualize_ocr(image, data): ...@@ -149,8 +149,8 @@ def visualize_ocr(image, data):
import fastdeploy as fd import fastdeploy as fd
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
"fastdeploy is required for visualizing results,please refer to \ "fastdeploy is required for visualizing results,please refer to "
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy") "https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
boxes = np.array(data['boxes']) boxes = np.array(data['boxes'])
text = np.array(data['text']) text = np.array(data['text'])
rec_scores = np.array(data['rec_scores']) rec_scores = np.array(data['rec_scores'])
...@@ -173,8 +173,8 @@ def visualize_headpose(image, data): ...@@ -173,8 +173,8 @@ def visualize_headpose(image, data):
import fastdeploy as fd import fastdeploy as fd
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
"fastdeploy is required for visualizing results,please refer to \ "fastdeploy is required for visualizing results,please refer to "
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy") "https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
euler_angles = np.array(data['euler_angles']) euler_angles = np.array(data['euler_angles'])
headpose_result = fd.C.vision.HeadPoseResult() headpose_result = fd.C.vision.HeadPoseResult()
......
...@@ -467,14 +467,20 @@ def launch_process(kwargs: dict): ...@@ -467,14 +467,20 @@ def launch_process(kwargs: dict):
logfilename = 'logfile-{}'.format(get_random_string(8)) logfilename = 'logfile-{}'.format(get_random_string(8))
while os.path.exists(os.path.join(FASTDEPLOYSERVER_PATH, logfilename)): while os.path.exists(os.path.join(FASTDEPLOYSERVER_PATH, logfilename)):
logfilename = 'logfile-{}'.format(get_random_string(8)) logfilename = 'logfile-{}'.format(get_random_string(8))
try:
p = Popen( p = Popen(
cmd, cmd,
stdout=open( stdout=open(
os.path.join(FASTDEPLOYSERVER_PATH, logfilename), 'w', os.path.join(FASTDEPLOYSERVER_PATH, logfilename),
'w',
buffering=1), buffering=1),
stderr=STDOUT, stderr=STDOUT,
universal_newlines=True, universal_newlines=True,
env=launch_env) env=launch_env)
except Exception:
raise RuntimeError(
"Failed to launch fastdeployserver,please check fastdeployserver is installed in environment."
)
server_name = start_args['server-name'] if start_args[ server_name = start_args['server-name'] if start_args[
'server-name'] else p.pid 'server-name'] else p.pid
with open( with open(
......
...@@ -156,8 +156,8 @@ class FastDeployServerApi(object): ...@@ -156,8 +156,8 @@ class FastDeployServerApi(object):
self._poll_zombie_process() self._poll_zombie_process()
if check_process_zombie(server_id) is True: if check_process_zombie(server_id) is True:
raise RuntimeError( raise RuntimeError(
"Server {} is down due to exception or killed,please check the reason according to the log, \ "Server {} is down due to exception or killed,please check the reason according to the log, "
then close this server.".format(server_id)) "then close this server.".format(server_id))
return return
@result() @result()
...@@ -207,8 +207,9 @@ class FastDeployServerApi(object): ...@@ -207,8 +207,9 @@ class FastDeployServerApi(object):
import fastdeploy as fd import fastdeploy as fd
except Exception: except Exception:
raise RuntimeError( raise RuntimeError(
"fastdeploy is required for visualizing results,please refer to \ "fastdeploy is required for visualizing results,please refer to "
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy") "https://github.com/PaddlePaddle/FastDeploy to install fastdeploy"
)
model_path = fd.download_model( model_path = fd.download_model(
name=pretrain_model_name, path=version_resource_dir) name=pretrain_model_name, path=version_resource_dir)
if model_path: if model_path:
......
...@@ -47,8 +47,8 @@ class ModelConvertApi(object): ...@@ -47,8 +47,8 @@ class ModelConvertApi(object):
file_handle = request.files['file'] file_handle = request.files['file']
data = file_handle.stream.read() data = file_handle.stream.read()
if format not in self.supported_formats: if format not in self.supported_formats:
raise RuntimeError('Model format {} is not supported. \ raise RuntimeError('Model format {} is not supported. "\
Only onnx and caffe models are supported now.'.format(format)) "Only onnx and caffe models are supported now.'.format(format))
result = {} result = {}
result['from'] = format result['from'] = format
result['to'] = 'paddle' result['to'] = 'paddle'
...@@ -99,14 +99,14 @@ class ModelConvertApi(object): ...@@ -99,14 +99,14 @@ class ModelConvertApi(object):
dirname, filename) dirname, filename)
if prototxt_path is None or weight_path is None: if prototxt_path is None or weight_path is None:
raise RuntimeError( raise RuntimeError(
".prototxt or .caffemodel file is missing in your archive file, \ ".prototxt or .caffemodel file is missing in your archive file, "
please check files uploaded.") "please check files uploaded.")
caffe2paddle(prototxt_path, weight_path, target_path, caffe2paddle(prototxt_path, weight_path, target_path,
None) None)
except Exception as e: except Exception as e:
raise RuntimeError( raise RuntimeError(
"[Convertion error] {}.\n Please open an issue at \ "[Convertion error] {}.\n Please open an issue at "
https://github.com/PaddlePaddle/X2Paddle/issues to report your problem." "https://github.com/PaddlePaddle/X2Paddle/issues to report your problem."
.format(e)) .format(e))
with self.lock: # we need to enter dirname(target_path) to archive, with self.lock: # we need to enter dirname(target_path) to archive,
# in case unneccessary directory added in archive. # in case unneccessary directory added in archive.
......
...@@ -202,9 +202,9 @@ class ProfilerReader(object): ...@@ -202,9 +202,9 @@ class ProfilerReader(object):
try: try:
import paddle import paddle
except Exception as e: except Exception as e:
print('Paddle is required to read protobuf file.\ print('Paddle is required to read protobuf file. "\
Please install [paddlepaddle](https://www.paddlepaddle.org.cn/install/quick?\ "Please install [paddlepaddle](https://www.paddlepaddle.org.cn/install/quick?"\
docurl=/documentation/docs/zh/develop/install/pip/linux-pip.html) first.' "docurl=/documentation/docs/zh/develop/install/pip/linux-pip.html) first.'
) )
raise RuntimeError(str(e)) raise RuntimeError(str(e))
if packaging.version.parse( if packaging.version.parse(
...@@ -223,10 +223,10 @@ class ProfilerReader(object): ...@@ -223,10 +223,10 @@ class ProfilerReader(object):
profile_result = ProfilerResult(content) profile_result = ProfilerResult(content)
except Exception as e: except Exception as e:
raise RuntimeError( raise RuntimeError(
"An error occurred while loading the protobuf file, which may be caused\ "An error occurred while loading the protobuf file, which may be caused "
by the outdated version of paddle that generated the profile file. \ "by the outdated version of paddle that generated the profile file. "
Please make sure protobuf file is exported by paddlepaddle version >= 2.4.0. \ "Please make sure protobuf file is exported by paddlepaddle version >= 2.4.0. "
Error message: {}".format(e)) "Error message: {}".format(e))
self.profile_result_queue.put( self.profile_result_queue.put(
(run, filename, worker_name, profile_result)) (run, filename, worker_name, profile_result))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册