Skip to content

Commit 1ba9b4c

Browse files
rainyflyheliqi
andauthored
fix a bug for string format (#1199)
Co-authored-by: heliqi <1101791222@qq.com>
1 parent acd6c6d commit 1ba9b4c

File tree

6 files changed

+50
-43
lines changed

6 files changed

+50
-43
lines changed

visualdl/component/inference/fastdeploy_client/http_client_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ def _create_client(self, server_url):
307307
return fastdeploy_client
308308
except Exception:
309309
raise RuntimeError(
310-
'Can not connect to server {}, please check your \
311-
server address'.format(server_url))
310+
'Can not connect to server {}, please check your '
311+
'server address'.format(server_url))
312312

313313
def infer(self, server_url, model_name, model_version, inputs):
314314
fastdeploy_client = self._create_client(server_url)

visualdl/component/inference/fastdeploy_client/visualizer.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def visualize_detection(image, data):
2727
import fastdeploy as fd
2828
except Exception:
2929
raise RuntimeError(
30-
"fastdeploy is required for visualizing results,please refer to \
31-
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
30+
"fastdeploy is required for visualizing results,please refer to "
31+
"https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
3232
boxes = np.array(data['boxes'])
3333
scores = np.array(data['scores'])
3434
label_ids = np.array(data['label_ids'])
@@ -49,8 +49,8 @@ def visualize_keypoint_detection(image, data):
4949
import fastdeploy as fd
5050
except Exception:
5151
raise RuntimeError(
52-
"fastdeploy is required for visualizing results,please refer to \
53-
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
52+
"fastdeploy is required for visualizing results,please refer to "
53+
"https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
5454
keypoints = np.array(data['keypoints'])
5555
scores = np.array(data['scores'])
5656
num_joints = np.array(data['num_joints'])
@@ -69,8 +69,8 @@ def visualize_face_detection(image, data):
6969
import fastdeploy as fd
7070
except Exception:
7171
raise RuntimeError(
72-
"fastdeploy is required for visualizing results,please refer to \
73-
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
72+
"fastdeploy is required for visualizing results,please refer to "
73+
"https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
7474
data = np.array(data['data'])
7575
scores = np.array(data['scores'])
7676
landmarks = np.array(data['landmarks'])
@@ -91,8 +91,8 @@ def visualize_face_alignment(image, data):
9191
import fastdeploy as fd
9292
except Exception:
9393
raise RuntimeError(
94-
"fastdeploy is required for visualizing results,please refer to \
95-
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
94+
"fastdeploy is required for visualizing results,please refer to "
95+
"https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
9696
landmarks = np.array(data['landmarks'])
9797

9898
facealignment_result = fd.C.vision.FaceAlignmentResult()
@@ -107,8 +107,8 @@ def visualize_segmentation(image, data):
107107
import fastdeploy as fd
108108
except Exception:
109109
raise RuntimeError(
110-
"fastdeploy is required for visualizing results,please refer to \
111-
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
110+
"fastdeploy is required for visualizing results,please refer to "
111+
"https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
112112
label_ids = np.array(data['label_ids'])
113113
score_map = np.array(data['score_map'])
114114
shape = np.array(data['shape'])
@@ -127,8 +127,8 @@ def visualize_matting(image, data):
127127
import fastdeploy as fd
128128
except Exception:
129129
raise RuntimeError(
130-
"fastdeploy is required for visualizing results,please refer to \
131-
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
130+
"fastdeploy is required for visualizing results,please refer to "
131+
"https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
132132
alpha = np.array(data['alpha'])
133133
foreground = np.array(data['foreground'])
134134
contain_foreground = data['contain_foreground']
@@ -149,8 +149,8 @@ def visualize_ocr(image, data):
149149
import fastdeploy as fd
150150
except Exception:
151151
raise RuntimeError(
152-
"fastdeploy is required for visualizing results,please refer to \
153-
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
152+
"fastdeploy is required for visualizing results,please refer to "
153+
"https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
154154
boxes = np.array(data['boxes'])
155155
text = np.array(data['text'])
156156
rec_scores = np.array(data['rec_scores'])
@@ -173,8 +173,8 @@ def visualize_headpose(image, data):
173173
import fastdeploy as fd
174174
except Exception:
175175
raise RuntimeError(
176-
"fastdeploy is required for visualizing results,please refer to \
177-
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
176+
"fastdeploy is required for visualizing results,please refer to "
177+
"https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
178178
euler_angles = np.array(data['euler_angles'])
179179

180180
headpose_result = fd.C.vision.HeadPoseResult()

visualdl/component/inference/fastdeploy_lib.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,20 @@ def launch_process(kwargs: dict):
467467
logfilename = 'logfile-{}'.format(get_random_string(8))
468468
while os.path.exists(os.path.join(FASTDEPLOYSERVER_PATH, logfilename)):
469469
logfilename = 'logfile-{}'.format(get_random_string(8))
470-
p = Popen(
471-
cmd,
472-
stdout=open(
473-
os.path.join(FASTDEPLOYSERVER_PATH, logfilename), 'w',
474-
buffering=1),
475-
stderr=STDOUT,
476-
universal_newlines=True,
477-
env=launch_env)
470+
try:
471+
p = Popen(
472+
cmd,
473+
stdout=open(
474+
os.path.join(FASTDEPLOYSERVER_PATH, logfilename),
475+
'w',
476+
buffering=1),
477+
stderr=STDOUT,
478+
universal_newlines=True,
479+
env=launch_env)
480+
except Exception:
481+
raise RuntimeError(
482+
"Failed to launch fastdeployserver,please check fastdeployserver is installed in environment."
483+
)
478484
server_name = start_args['server-name'] if start_args[
479485
'server-name'] else p.pid
480486
with open(

visualdl/component/inference/fastdeploy_server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ def check_server_alive(self, server_id):
156156
self._poll_zombie_process()
157157
if check_process_zombie(server_id) is True:
158158
raise RuntimeError(
159-
"Server {} is down due to exception or killed,please check the reason according to the log, \
160-
then close this server.".format(server_id))
159+
"Server {} is down due to exception or killed,please check the reason according to the log, "
160+
"then close this server.".format(server_id))
161161
return
162162

163163
@result()
@@ -207,8 +207,9 @@ def download_pretrain_model(self, cur_dir, model_name, version,
207207
import fastdeploy as fd
208208
except Exception:
209209
raise RuntimeError(
210-
"fastdeploy is required for visualizing results,please refer to \
211-
https://github.com/PaddlePaddle/FastDeploy to install fastdeploy")
210+
"fastdeploy is required for visualizing results,please refer to "
211+
"https://github.com/PaddlePaddle/FastDeploy to install fastdeploy"
212+
)
212213
model_path = fd.download_model(
213214
name=pretrain_model_name, path=version_resource_dir)
214215
if model_path:

visualdl/component/inference/model_convert_server.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def convert_model(self, format):
4747
file_handle = request.files['file']
4848
data = file_handle.stream.read()
4949
if format not in self.supported_formats:
50-
raise RuntimeError('Model format {} is not supported. \
51-
Only onnx and caffe models are supported now.'.format(format))
50+
raise RuntimeError('Model format {} is not supported. "\
51+
"Only onnx and caffe models are supported now.'.format(format))
5252
result = {}
5353
result['from'] = format
5454
result['to'] = 'paddle'
@@ -99,14 +99,14 @@ def convert_model(self, format):
9999
dirname, filename)
100100
if prototxt_path is None or weight_path is None:
101101
raise RuntimeError(
102-
".prototxt or .caffemodel file is missing in your archive file, \
103-
please check files uploaded.")
102+
".prototxt or .caffemodel file is missing in your archive file, "
103+
"please check files uploaded.")
104104
caffe2paddle(prototxt_path, weight_path, target_path,
105105
None)
106106
except Exception as e:
107107
raise RuntimeError(
108-
"[Convertion error] {}.\n Please open an issue at \
109-
https://github.com/PaddlePaddle/X2Paddle/issues to report your problem."
108+
"[Convertion error] {}.\n Please open an issue at "
109+
"https://github.com/PaddlePaddle/X2Paddle/issues to report your problem."
110110
.format(e))
111111
with self.lock: # we need to enter dirname(target_path) to archive,
112112
# in case unneccessary directory added in archive.

visualdl/component/profiler/profiler_reader.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ def _load_profiler_protobuf(run, filename, worker_name):
202202
try:
203203
import paddle
204204
except Exception as e:
205-
print('Paddle is required to read protobuf file.\
206-
Please install [paddlepaddle](https://www.paddlepaddle.org.cn/install/quick?\
207-
docurl=/documentation/docs/zh/develop/install/pip/linux-pip.html) first.'
205+
print('Paddle is required to read protobuf file. "\
206+
"Please install [paddlepaddle](https://www.paddlepaddle.org.cn/install/quick?"\
207+
"docurl=/documentation/docs/zh/develop/install/pip/linux-pip.html) first.'
208208
)
209209
raise RuntimeError(str(e))
210210
if packaging.version.parse(
@@ -223,10 +223,10 @@ def _load_profiler_protobuf(run, filename, worker_name):
223223
profile_result = ProfilerResult(content)
224224
except Exception as e:
225225
raise RuntimeError(
226-
"An error occurred while loading the protobuf file, which may be caused\
227-
by the outdated version of paddle that generated the profile file. \
228-
Please make sure protobuf file is exported by paddlepaddle version >= 2.4.0. \
229-
Error message: {}".format(e))
226+
"An error occurred while loading the protobuf file, which may be caused "
227+
"by the outdated version of paddle that generated the profile file. "
228+
"Please make sure protobuf file is exported by paddlepaddle version >= 2.4.0. "
229+
"Error message: {}".format(e))
230230
self.profile_result_queue.put(
231231
(run, filename, worker_name, profile_result))
232232

0 commit comments

Comments
 (0)