Cannot import 'crop_to_bbox' from 'acvl_utils #2588
Replies: 4 comments 2 replies
-
I'm also getting the same error. I searched for the crop_to_bbox to manually also to run it, but was not able to find any. |
Beta Was this translation helpful? Give feedback.
-
You should install acvl_utils==0.2 |
Beta Was this translation helpful? Give feedback.
-
Problem could be solved by downgrading acvl_utils from version 0.2.1 to 0.2 |
Beta Was this translation helpful? Give feedback.
-
I had the same problem and I solved it just uninstalling the acvl_utils and installing the 0.2 as the guys are saying. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I trained an nnUNetv2 in google colab and now Im trying to do inference now. Apparently something might have changed in the utilities library, because whenever I try to predict using:
!nnUNetv2_predict -d Dataset001_ChromfDatas -i /content/drive/MyDrive/nnUNet/nnUNet_raw/imagesTs -o /content/drive/MyDrive/nnUNet/nnUNet_results/Dataset001_ChromfDatas/inference -f 0 1 2 3 4 -tr nnUNetTrainer -c 2d -p nnUNetPlans
First I get the error:
Traceback (most recent call last):
File "/usr/local/bin/nnUNetv2_predict", line 5, in
from nnunetv2.inference.predict_from_raw_data import predict_entry_point
File "/usr/local/lib/python3.10/dist-packages/nnunetv2/inference/predict_from_raw_data.py", line 22, in
from nnunetv2.inference.data_iterators import PreprocessAdapterFromNpy, preprocessing_iterator_fromfiles,
File "/usr/local/lib/python3.10/dist-packages/nnunetv2/inference/data_iterators.py", line 12, in
from nnunetv2.preprocessing.preprocessors.default_preprocessor import DefaultPreprocessor
File "/usr/local/lib/python3.10/dist-packages/nnunetv2/preprocessing/preprocessors/default_preprocessor.py", line 25, in
from nnunetv2.preprocessing.cropping.cropping import crop_to_nonzero
File "/usr/local/lib/python3.10/dist-packages/nnunetv2/preprocessing/cropping/cropping.py", line 5, in
from acvl_utils.cropping_and_padding.bounding_boxes import get_bbox_from_mask, crop_to_bbox, bounding_box_to_slice
File "/usr/local/lib/python3.10/dist-packages/acvl_utils/cropping_and_padding/bounding_boxes.py", line 100, in
image: Union[torch.Tensor, np.ndarray, blosc2.ndarray.NDArray],
AttributeError: module 'blosc2' has no attribute 'ndarray'
I tried restarting the session, and the verify_dataset_integrity is throwing the same error now.
I checked the acvl_utils and the blosc2 versions:
Name: acvl_utils
Version: 0.2.1
Requires: batchgenerators, connected-components-3d, numpy, scikit-image, SimpleITK, torch
Required-by: nnunetv2
Name: blosc2
Version: 2.0.0
Summary: Python wrapper for the C-Blosc2 library.
Location: /usr/local/lib/python3.10/dist-packages
Requires: msgpack
Required-by: tables
I went down to find the problem in the problematic file below.
File "/usr/local/lib/python3.10/dist packages/acvl_utils/cropping_and_padding/bounding_boxes.py", line 100, in
image: Union[torch.Tensor, np.ndarray, blosc2.ndarray.NDArray],
Trying the bruteforce solution of replacing the last line with
image: Union[torch.Tensor, np.ndarray]
didnt help, because it lead to another issue whith importing a nonexistent name crop_to_box from 'acvl_utils.cropping_and_padding.bounding_boxes, with the following error:
Traceback (most recent call last):
File "/usr/local/bin/nnUNetv2_plan_and_preprocess", line 5, in
from nnunetv2.experiment_planning.plan_and_preprocess_entrypoints import plan_and_preprocess_entry
File "/usr/local/lib/python3.10/dist-packages/nnunetv2/experiment_planning/plan_and_preprocess_entrypoints.py", line 2, in
from nnunetv2.experiment_planning.plan_and_preprocess_api import extract_fingerprints, plan_experiments, preprocess
File "/usr/local/lib/python3.10/dist-packages/nnunetv2/experiment_planning/plan_and_preprocess_api.py", line 8, in
from nnunetv2.experiment_planning.dataset_fingerprint.fingerprint_extractor import DatasetFingerprintExtractor
File "/usr/local/lib/python3.10/dist-packages/nnunetv2/experiment_planning/dataset_fingerprint/fingerprint_extractor.py", line 13, in
from nnunetv2.preprocessing.cropping.cropping import crop_to_nonzero
File "/usr/local/lib/python3.10/dist-packages/nnunetv2/preprocessing/cropping/cropping.py", line 5, in
from acvl_utils.cropping_and_padding.bounding_boxes import get_bbox_from_mask, crop_to_bbox, bounding_box_to_slice
ImportError: cannot import name 'crop_to_bbox' from 'acvl_utils.cropping_and_padding.bounding_boxes' (/usr/local/lib/python3.10/dist-packages/acvl_utils/cropping_and_padding/bounding_boxes.py)
Is anyone else facing this issue too these days?
I found something that might be related to this issue, but couldn't relate to my actual problem:
Blosc/python-blosc2#187
Any help is appreciated.
Beta Was this translation helpful? Give feedback.
All reactions