I have train model using keras-retinanet for object Detection and Changing Anchor size as per below in config.ini file:
[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:
!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???
Convert your trained model for inference -