[英]How to set --config config.ini during Prediction?
I have train model using keras-retinanet for object Detection and Changing Anchor size as per below in config.ini file:我在 config.ini 文件中使用 keras-retinanet 训练模型进行对象检测和更改锚点大小,如下所示:
[anchor_parameters]
sizes = 16 32 64 128 256
strides = 8 16 32 64 128
ratios = 0.5 1 2 3
scales = 1 1.2 1.6
I have save this config in file config.ini and I put this as input to training as below:我已将此配置保存在文件 config.ini 中,并将其作为训练的输入,如下所示:
!python keras_retinanet/bin/train.py \
--freeze-backbone \
--random-transform \
--weights {PRETRAINED_MODEL} \
--batch-size 1 \
--steps 500 \
--epochs 5 \
--config config.ini \
csv annotations.csv classes.csv
And Training Goes Good but how to use this file during Prediction in given function?训练效果很好,但是如何在给定函数的预测期间使用此文件?
convert_model(model,nms=True, class_specific_filter=True, anchor_params=None)??
I am using Below Code to Load Model我正在使用下面的代码加载模型
model_path = os.path.join('snapshots', sorted(os.listdir('snapshots'), reverse=True)[0])
model = models.load_model(model_path, backbone_name='resnet50')
model = models.convert_model(model,anchor_params=anchor_parameters)
labels_to_names = pd.read_csv(CLASSES_FILE, header=None).T.loc[0].to_dict()
Convert Model Works like as Below:转换模型工作如下:
def convert_model(model, nms=True, class_specific_filter=True, anchor_params=None):
""" Converts a training model to an inference model.
Args
model : A retinanet training model.
nms : Boolean, whether to add NMS filtering to the converted model.
class_specific_filter : Whether to use class specific filtering or filter for the best scoring class only.
anchor_params : Anchor parameters object. If omitted, default values are used.
Returns
A keras.models.Model object.
Raises
ImportError: if h5py is not available.
ValueError: In case of an invalid savefile.
"""
from .retinanet import retinanet_bbox
return retinanet_bbox(model=model, nms=nms, class_specific_filter=class_specific_filter, anchor_params=anchor_params)
How can I set Config.ini or Anchor Parameters during Prediction or load model as above code???如何在预测或加载模型期间设置 Config.ini 或 Anchor 参数如上述代码???
转换您训练有素的模型以进行推理 -
keras_retinanet/bin/convert.py --config config.ini trained_model.h5 converted_model.h5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.