Home > database >  Export custom model training data in matlab
Export custom model training data in matlab

Time:07-12

I new to matlab and i am using the example here to train a custom model. I am training the yolov2 object detector using -

[detector,info] = trainYOLOv2ObjectDetector(preprocessedTrainingData,lgraph,options);

Previously i have created custom yolov5 model in python which results in a .pt file which can be used in future. But in the matlab example here, there is no output file. I have to train the model every time. Is there any way to get the custom trained model file?

CodePudding user response:

You can use

detector = trainYOLOv2ObjectDetector(trainingData,checkpoint,options) 

to resume training from a specific checkpoint. The checkpoint is specified as a yolov2ObjectDetector object. This means that you would want to save this checkpoint during your initial training of the YOLOv2 model periodically. To do that specify a CheckpointPath before training.

You can then load the checkpoint like this:

data = load('/yourpathtothemodel/checkpath/yolov2_checkpoint__216__2018_11_16__13_34_30.mat');
checkpoint = data.detector;

So the initial training of your model should look similar to this:

detector = trainYOLOv2ObjectDetector(trainingData,lgraph,options)

where options is defined before the execution of the training method and has the CheckpointPath to your local dictionary:

options = trainingOptions('sgdm',...
      'InitialLearnRate',0.001,...
      'Verbose',true,...
      'MiniBatchSize',16,...
      'MaxEpochs',30,...
      'Shuffle','never',...
      'VerboseFrequency',30,...
      'CheckpointPath',"C:\yourpathtothemodel);
  • Related