From 4a4e757dfb00d7bf010e23372df7c01f61e0f631 Mon Sep 17 00:00:00 2001 From: appukuttan-shailesh Date: Thu, 20 Jun 2024 15:39:59 +0200 Subject: [PATCH] replace imp with importlib --- HD_BET/run.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/HD_BET/run.py b/HD_BET/run.py index 8c6f08d..c54f3e3 100755 --- a/HD_BET/run.py +++ b/HD_BET/run.py @@ -3,7 +3,7 @@ import SimpleITK as sitk from HD_BET.data_loading import load_and_preprocess, save_segmentation_nifti from HD_BET.predict_case import predict_case_3D_net -import imp +import importlib.util from HD_BET.utils import postprocess_prediction, SetNetworkToVal, get_params_fname, maybe_download_parameters import os import HD_BET @@ -53,7 +53,9 @@ def run_hd_bet(mri_fnames, output_fnames, mode="accurate", config_file=os.path.j assert all([os.path.isfile(i) for i in list_of_param_files]), "Could not find parameter files" - cf = imp.load_source('cf', config_file) + spec = importlib.util.spec_from_file_location("cf", config_file) + cf = importlib.util.module_from_spec(spec) + spec.loader.exec_module(cf) cf = cf.config() net, _ = cf.get_network(cf.val_use_train_mode, None)