fix for retrain in headless mode issue #894

fix for retrain in headless mode issue #894