【需求】支持自定义配置,自定义字典的预测
panxua opened this issue · comments
当前推理的网络构建使用如下接口
mindocr/tools/infer/text/predict_rec.py
Line 80 in 25bd212
貌似仅支持硬编码的如下配置
https://github.com/mindspore-lab/mindocr/blob/25bd212875bf5035c0ac3b015181cab4ee6276f0/tools/infer/text/predict_rec.py#L32C1-L38C2
自定义字典,改变输出序列长度后不能使用该脚本推理,能否提供支持自定义配置的接口以及指导。
本问题已由 #648 解决 ,现在可以通过tools/infer/text/predict_from_yaml.py
脚本完成自定义的推理,具体说明请看文档tools/infer/text/README.MD
。
- 以自定义configs/rec/crnn/crnn_vgg7.yaml为例,通过自定义
predict
字段,定义模型预测的各参数。
predict:
ckpt_load_path: ./tmp_rec/best.ckpt
vis_font_path: tools/utils/simfang.ttf
dataset_sink_mode: False
dataset:
type: PredictDataset
dataset_root: path/to/dataset_root
data_dir: predict_result/crop
sample_ratio: 1.0
shuffle: False
transform_pipeline:
- DecodeImage:
img_mode: RGB
to_float32: False
- RecResizeNormForInfer:
target_height: 32
target_width: 100
keep_ratio: False
padding: False
norm_before_pad: False
- ToCHWImage:
# the order of the dataloader list, matching the network input and the input labels for the loss function, and optional data for debug/visaulize
output_columns: ['image', 'img_path']
net_input_column_index: [0] # input indices for network forward func in output_columns
# label_column_index: [1, 2] # input indices marked as label
loader:
shuffle: False # TODO: tbc
batch_size: 2
drop_remainder: True
max_rowsize: 12
num_workers: 8
- 使用
python tools/infer/text/predict_from_yaml.py. -image_dir xxx --rec_config configs/rec/crnn/crnn_vgg7.yaml --mode rec
完成推理。