def predict(self, configs, progress=None): configs = ConfigSpec(configs) opt_model = OptModel() opt_model.add_child_spec(configs, 'configs') zazu = ZaZu(opt_model, remote=True) zazu.run_inference()
def search(self, configs, progress=None): configs = ConfigSpec(configs) opt_model = OptModel() opt_model.add_child_spec(configs, 'configs') zazu = ZaZu(opt_model, remote=True) zazu.find_best_model() zazu.hp_search() checkpoint_paths_list = glob.glob('*checkpoint*.pt') save_info = { 'package_name': self.package_name, 'execution_id': progress.execution.id } project_name = opt_model.dataloop['project'] project = dl.projects.get(project_name=project_name) # model_name = opt_model.name # model_obj = dl.models.get(model_name=model_name) logger.info('uploading checkpoints.....') for checkpoint_path in checkpoint_paths_list: # model_obj.checkpoints.upload(checkpoint_name=checkpoint_path.split('.')[0], local_path=checkpoint_path) project.artifacts.upload(filepath=checkpoint_path, package_name=save_info['package_name'], execution_id=save_info['execution_id']) logger.info('finished uploading checkpoints')
def train(self, configs, progress=None): configs = ConfigSpec(configs) opt_model = OptModel() opt_model.add_child_spec(configs, 'configs') zazu = ZaZu(opt_model, remote=True) zazu.train_new_model()
def search(self, configs, progress=None): configs = ConfigSpec(configs) opt_model = OptModel() opt_model.add_child_spec(configs, 'configs') zazu = ZaZu(opt_model, remote=True) zazu.find_best_model() zazu.hp_search()
dataset_obj = get_dataset_obj(configs['dataloop']) id = dataset_obj.project.id if args.search: zazu_service.execute(function_name='search', execution_input=inputs, project_id=id) if args.predict: zazu_service.execute(function_name='predict', execution_input=inputs, project_id=id) else: logger = init_logging(__name__) this_path = path = os.getcwd() configs_path = os.path.join(this_path, 'configs.json') configs = ConfigSpec(configs_path) opt_model = OptModel() opt_model.add_child_spec(configs, 'configs') zazu = ZaZu(opt_model, remote=args.remote) if args.search: zazu.find_best_model() zazu.hp_search() if args.train: zazu.train_new_model() if args.predict: zazu.run_inference() if args.predict_once: zazu.one_time_inference('/home/noam/0120122798.jpg', 'checkpoint0.pt')
parser.add_argument("--update", action='store_true', default=False) parser.add_argument("--search", action='store_true', default=False) parser.add_argument("--train", action='store_true', default=False) parser.add_argument("--predict", action='store_true', default=False) parser.add_argument("--zazu_timer", action='store_true', default=False) parser.add_argument("--checkpoint_path", type=str, default='/home/noam/ZazuML/best_checkpoint.pt') parser.add_argument("--dataset_path", type=str, default='') parser.add_argument("--output_path", type=str, default='') args = parser.parse_args() with open('configs.json', 'r') as fp: configs = json.load(fp) logger = init_logging(__name__) this_path = path = os.getcwd() configs_path = os.path.join(this_path, 'configs.json') configs = ConfigSpec('configs.json') opt_model = OptModel('models.json') opt_model.add_child_spec(configs, 'configs') zazu = ZaZu(opt_model, remote=args.remote) if args.search: zazu.hp_search() if args.train: adapter = AdapterModel() adapter.load(checkpoint_path=args.checkpoint_path) adapter.train() print('model checkpoint is saved to: ', adapter.checkpoint_path) if args.predict: predict(pred_on_path=args.dataset_path, output_path=args.output_path, checkpoint_path=args.checkpoint_path, threshold=0.5)