def test_wrapper(args: Namespace) -> None: model_name = args.model model = load_model(model_name) if args.edit: predictions, data_iter, metadata = test_model_masked( model, args.dataset, args.edit) edit_predictions(predictions, data_iter, metadata) else: predictions, test_iter = test_model_masked(model, args.dataset, args.edit) plot_predictions(predictions, test_iter)
def run_gui(folder: str, model) -> None: predictions, data_iter, metadata = test_model_masked( model, folder, True, dems=512 ) edit_predictions( predictions, data_iter, metadata, dem=512 )
def test_wrapper(args: Namespace) -> None: model_name = args.model model = load_model(model_name) if model_type(model) != dataset_type(args.dataset): print("ERROR: This dataset is not compatible with your model") return if dataset_type(args.dataset) == ModelType.MASKED: predictions, test_iter = test_model_masked(model, args.dataset) plot_masked_predictions(predictions, test_iter, args.dataset) else: details, confusion_matrix = test_model_binary(model, args.dataset) model_dir = os.path.dirname(path_from_model_name(model_name)) with open(os.path.join(model_dir, 'results.csv'), 'w') as f: write_dict_to_csv(details, f) plot_confusion_chart(confusion_matrix) plot_predictions(details['Percent'], args.dataset)
def mkdata_wrapper(args: Namespace) -> None: etl_wm() setup_data(args.size) dataset_fpath = f"syntheticTriainingData{date.isoformat(date.today())}" dataset_dir = os.path.join('datasets', args.directory) model_name = args.model model = load_model(model_name) if args.environment: final_dataset_fpath = os.path.join( dataset_dir, f'{args.dataset}_{args.environment}') dataset = os.path.join(args.directory, f'{args.dataset}_{args.environment}') else: final_dataset_fpath = os.path.join('datasets', args.dataset) dataset = args.dataset if not os.path.isdir(dataset_dir): os.mkdir(dataset_dir) if not os.path.isdir(final_dataset_fpath): os.mkdir(final_dataset_fpath) for folder in os.listdir(dataset_fpath): for img in os.listdir(os.path.join(dataset_fpath, folder)): os.rename(os.path.join(dataset_fpath, folder, img), os.path.join(final_dataset_fpath, img)) shutil.rmtree(dataset_fpath) move_imgs(final_dataset_fpath) prepare_data(final_dataset_fpath, 0.2) predictions, data_iter, metadata = test_model_masked(model, dataset, edit=True) edit_predictions(predictions, data_iter, metadata)