x
This commit is contained in:
@@ -31,7 +31,18 @@ def patch_b_predict_rec_batch(infer_dir):
|
||||
"""predict_rec.py: 批次填充"""
|
||||
f = os.path.join(infer_dir, 'predict_rec.py')
|
||||
c = open(f).read()
|
||||
old = r'(^ *)(norm_img_batch = np\.concatenate\(norm_img_batch\))'
|
||||
# 兼容 mineru 3.4.0:赋值行可能是
|
||||
# norm_img_batch = np.concatenate(norm_img_batch)
|
||||
# 或
|
||||
# norm_img_batch = np.ascontiguousarray(np.concatenate(norm_img_batch))
|
||||
# 用宽松正则匹配「norm_img_batch = ...np.concatenate(norm_img_batch)...」整行
|
||||
old = (
|
||||
r'(^ *)(norm_img_batch\s*=\s*'
|
||||
r'(?:np\.ascontiguousarray\()?' # 可选 ascontiguousarray 包裹
|
||||
r'np\.concatenate\(norm_img_batch\)'
|
||||
r'(?:\))?' # 可选闭合括号
|
||||
r')'
|
||||
)
|
||||
new = (
|
||||
r'\1actual_batch_size = len(norm_img_batch)\n'
|
||||
r'\1if actual_batch_size < batch_num:\n'
|
||||
|
||||
Reference in New Issue
Block a user