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