Fixed some crashes produced in the training process due to the incorrect initialization of the detector. Also adjusted the cancelation of the training process.