while running aws lambda function and doing inference with DL model over container running in lambda, when i am downloading my model from s3 it is running but when i instantiate a StarDist2D(conf) object it is giving this error. Not sure whether it is due to Stardist or something instance object or something else since there is timestamp infront of error as you can see in question heading.
Code for lambda_handler
def download_model_from_s3(bucket_name, model_key, local_model_path): try: s3_client.download_file(bucket_name, model_key, local_model_path) return True except Exception as e: print(f"Error downloading model file from S3: {e}") return Falselocal_model_path = '/tmp/'+ model_file_namedef download_model_from_s3(bucket_name, model_key, local_model_path): try: s3_client.download_file(bucket_name, model_key, local_model_path) return True except Exception as e: print(f"Error downloading model file from S3: {e}") return False def lambda_handler(event, context): # Check if the event is an S3 event print("this is event",event) if 'Records' in event and len(event['Records']) > 0 and 's3' in event['Records'][0]: bucket = event['Records'][0]['s3']['bucket']['name'] key = urllib.parse.unquote_plus(event['Records'][0]['s3']['object']['key'], encoding='utf-8') print("this is key",key) image_name = key.split("/")[-1] print("this is image_name",image_name) # Check if the uploaded object is in the validationimages folder if key.startswith('ValidationImages/'): # Process the uploaded image here print("line no 67") np.random.seed(42) image_path = '/tmp/'+image_name s3_client.download_file(bucket_name, key, image_path) def imreadReshape(key): if ".tif" in image_name: imageRead = imread(image_path) if np.ndim(imageRead) == 2: return imageRead imageRead = np.array(imageRead) imageRead = cv2.resize(imageRead,(768,768)) return imageRead[:,:,0] else: print("line no 80") imageRead = cv2.imread(image_path) print("line no 82") if np.ndim(imageRead) == 2: return imageRead imageRead = cv2.resize(imageRead,(768,768)) return imageRead[:,:,0] X_val = [image_name] X_val = list(map(imreadReshape,X_val)) n_channel = 1 if X_val[0].ndim == 2 else X_val[0].shape[-1] #If no third dim. then number of channels = 1. Otherwise get the num channels from the last dim. axis_norm = (0,1) if n_channel > 1: print("Normalizing image channels %s." % ('jointly' if axis_norm is None or 2 in axis_norm else 'independently')) sys.stdout.flush() X_val = [x/255 for x in X_val] rng = np.random.RandomState(42) print(Config2D.__doc__) gputools_available() n_rays = 32 #ok use_gpu = True and gputools_available() #ok grid = (2,2) # ok conf = Config2D ( n_rays = n_rays, grid = grid, use_gpu = use_gpu, n_channel_in = n_channel, train_patch_size = (768,768) ) if download_model_from_s3(bucket_name, model_key, local_model_path): ## Load the model new_model = tf.keras.models.load_model(local_model_path) print("Load Model Complete") model_load = StarDist2D(conf)