I was following the installation and usage instructions, but encountered an error while segmenting the middle slice. Could you please assist in resolving this issue?
Slicer 5.6.2
Cuda 12.6
Driver Version 560.76
Windows 11
Error in Slicer:
Traceback (most recent call last):
File "E:/workProjects/PY/MedSAMSlicer/slicer/SAM2/SAM2/SAM2.py", line 484, in getMiddleMask
segmentation_mask = np.load(result_path, allow_pickle=True)['segs']
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\numpy\lib\npyio.py", line 263, in getitem
raise KeyError(f"{key} is not a file in the archive")
KeyError: 'segs is not a file in the archive'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 625, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\Users\HYGEA\AppData\Local\Temp\tmpqdybwzjy\result.npz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 805, in onerror
_os.unlink(path)
PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\Users\HYGEA\AppData\Local\Temp\tmpqdybwzjy\result.npz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:/workProjects/PY/MedSAMSlicer/slicer/SAM2/SAM2/SAM2.py", line 485, in getMiddleMask
self.showSegmentation(segmentation_mask, set_middle_mask=True)
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 830, in exit
self.cleanup()
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 834, in cleanup
self._rmtree(self.name)
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 816, in _rmtree
_shutil.rmtree(name, onerror=onerror)
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 749, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 627, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 808, in onerror
cls._rmtree(path)
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 816, in _rmtree
_shutil.rmtree(name, onerror=onerror)
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 749, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 608, in _rmtree_unsafe
onerror(os.scandir, path, sys.exc_info())
File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 605, in _rmtree_unsafe
with os.scandir(path) as scandir_it:
NotADirectoryError: [WinError 267] 目录名称无效。: 'C:\Users\HYGEA\AppData\Local\Temp\tmpqdybwzjy\result.npz'
then I ran "python infer_video_tiny_debug.py --img_path 'img_data.npz' --gts_path 'gts.npz' --propagate Y --checkpoint tiny“, got error :
Traceback (most recent call last):
File "E:\workProjects\PY\MedSAMSlicer\infer_video_tiny_debug.py", line 297, in
infer_3d(img_npz_file, gts_file, propagate)
File "C:\Users\HYGEA\anaconda3\envs\sam2\Lib\site-packages\torch\utils_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "E:\workProjects\PY\MedSAMSlicer\infer_video_tiny_debug.py", line 208, in infer_3d
gts = np.load(gts_file, 'r', allow_pickle=True)['segs'] if gts_file != 'X' else None
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HYGEA\anaconda3\envs\sam2\Lib\site-packages\numpy\lib\npyio.py", line 427, in load
fid = stack.enter_context(open(os_fspath(file), "rb"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'gts.npz'
Hello,
I was following the installation and usage instructions, but encountered an error while segmenting the middle slice. Could you please assist in resolving this issue?
Slicer 5.6.2 Cuda 12.6 Driver Version 560.76 Windows 11
Error in Slicer: Traceback (most recent call last): File "E:/workProjects/PY/MedSAMSlicer/slicer/SAM2/SAM2/SAM2.py", line 484, in getMiddleMask segmentation_mask = np.load(result_path, allow_pickle=True)['segs'] File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\site-packages\numpy\lib\npyio.py", line 263, in getitem raise KeyError(f"{key} is not a file in the archive") KeyError: 'segs is not a file in the archive'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 625, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\Users\HYGEA\AppData\Local\Temp\tmpqdybwzjy\result.npz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 805, in onerror _os.unlink(path) PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\Users\HYGEA\AppData\Local\Temp\tmpqdybwzjy\result.npz'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "E:/workProjects/PY/MedSAMSlicer/slicer/SAM2/SAM2/SAM2.py", line 485, in getMiddleMask self.showSegmentation(segmentation_mask, set_middle_mask=True) File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 830, in exit self.cleanup() File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 834, in cleanup self._rmtree(self.name) File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 816, in _rmtree _shutil.rmtree(name, onerror=onerror) File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 749, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 627, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 808, in onerror cls._rmtree(path) File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\tempfile.py", line 816, in _rmtree _shutil.rmtree(name, onerror=onerror) File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 749, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 608, in _rmtree_unsafe onerror(os.scandir, path, sys.exc_info()) File "C:\Users\HYGEA\AppData\Local\slicer.org\Slicer 5.6.2\lib\Python\Lib\shutil.py", line 605, in _rmtree_unsafe with os.scandir(path) as scandir_it: NotADirectoryError: [WinError 267] 目录名称无效。: 'C:\Users\HYGEA\AppData\Local\Temp\tmpqdybwzjy\result.npz'
then I ran "python infer_video_tiny_debug.py --img_path 'img_data.npz' --gts_path 'gts.npz' --propagate Y --checkpoint tiny“, got error : Traceback (most recent call last): File "E:\workProjects\PY\MedSAMSlicer\infer_video_tiny_debug.py", line 297, in
infer_3d(img_npz_file, gts_file, propagate)
File "C:\Users\HYGEA\anaconda3\envs\sam2\Lib\site-packages\torch\utils_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "E:\workProjects\PY\MedSAMSlicer\infer_video_tiny_debug.py", line 208, in infer_3d
gts = np.load(gts_file, 'r', allow_pickle=True)['segs'] if gts_file != 'X' else None
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\HYGEA\anaconda3\envs\sam2\Lib\site-packages\numpy\lib\npyio.py", line 427, in load
fid = stack.enter_context(open(os_fspath(file), "rb"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'gts.npz'