BSHM人像抠图,小白,这个报错,大佬给指点下,谢谢了。

FileNotFoundError: [Errno 2] No such file or directory: ‘‪D:.png’


FileNotFoundError Traceback (most recent call last)
Cell In[2], line 7
4 from modelscope.outputs import OutputKeys
6 portrait_matting = pipeline(Tasks.portrait_matting,model=’damo/cv_unet_image-matting’)
—-> 7 result = portrait_matting(‘‪D:\1\1.png’)
8 cv2.imwrite(‘result.png’, result[OutputKeys.OUTPUT_IMG])

File /opt/conda/lib/python3.8/site-packages/modelscope/pipelines/base.py:219, in Pipeline.call(self, input, args, **kwargs)
216 return self._process_iterator(input,
args, kwargs)
218 else:
–> 219 output = self._process_single(input, *args,
kwargs)
220 return output

File /opt/conda/lib/python3.8/site-packages/modelscope/pipelines/base.py:247, in Pipeline._process_single(self, input, args, *kwargs)
245 postprocess_params = kwargs.get(‘postprocess_params’, {})
246 self._check_input(input)
–> 247 out = self.preprocess(input,
preprocess_params)
249 with device_placement(self.framework, self.device_name):
250 if self.framework == Frameworks.torch:

File /opt/conda/lib/python3.8/site-packages/modelscope/pipelines/cv/image_matting_pipeline.py:55, in ImageMattingPipeline.preprocess(self, input)
54 def preprocess(self, input: Input) -> Dict[str, Any]:
—> 55 img = LoadImage.convert_to_ndarray(input)
56 img = img.astype(float)
57 result = {‘img’: img}

File /opt/conda/lib/python3.8/site-packages/modelscope/preprocessors/image.py:89, in LoadImage.convert_to_ndarray(input)
86 @staticmethod
87 def convert_to_ndarray(input) -> ndarray:
88 if isinstance(input, str):
—> 89 img = np.array(load_image(input))
90 elif isinstance(input, PIL.Image.Image):
91 img = np.array(input.convert(‘RGB’))

File /opt/conda/lib/python3.8/site-packages/modelscope/preprocessors/image.py:133, in load_image(image_path_or_url)
127 “”” simple interface to load an image from file or url
128
129 Args:
130 image_path_or_url (str): image file path or http url
131 “””
132 loader = LoadImage()
–> 133 return loader(image_path_or_url)[‘img’]

File /opt/conda/lib/python3.8/site-packages/modelscope/preprocessors/image.py:57, in LoadImage.call(self, input)
55 img_shape = (img_h, img_w, img_c)
56 elif self.backend == ‘pillow’:
—> 57 bytes = File.read(image_path_or_url)
58 # TODO @wenmeng.zwm add opencv decode as optional
59 # we should also look at the input format which is the most commonly
60 # used in Mind’ image related models
61 with io.BytesIO(bytes) as infile:

File /opt/conda/lib/python3.8/site-packages/modelscope/fileio/file.py:274, in File.read(uri)
265 “””Read data from a given filepath with ‘rb’ mode.
266
267 Args:
(…)
271 bytes: Expected bytes object.
272 “””
273 storage = File._get_storage(uri)
–> 274 return storage.read(uri)

File /opt/conda/lib/python3.8/site-packages/modelscope/fileio/file.py:53, in LocalStorage.read(self, filepath)
44 def read(self, filepath: Union[str, Path]) -> bytes:
45 “””Read data from a given filepath with ‘rb’ mode.
46
47 Args:
(…)
51 bytes: Expected bytes object.
52 “””
—> 53 with open(filepath, ‘rb’) as f:
54 content = f.read()
55 return content

FileNotFoundError: [Errno 2] No such file or directory: ‘‪D:.png’

「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!
=====这是一个广告位,招租中,联系qq 78315851====
阿里云
3 条回复 A 作者 M 管理员
  1. 它似乎表示无法找到文件 “‪D:.png” 。该文件路径中的字节顺序标记(BOM)可能导致文件路径识别错误,建议将文件名中删除 BOM 或将文件路径转义成字符串进行引用即可解决此问题。
    另外,可以检查该文件是否存在,并确保脚本有足够的权限读取该文件。请确保文件路径正确无误,并遵循相关操作系统的文件命名规则,以免发生此类错误。

  2. 这个错误信息“FileNotFoundError:[Errno 2] No such file or directory”表明指定路径“‪D:11.png”下的文件不存在。这可能是因为文件名或路径中的拼写错误,或者是文件已被移动或删除。请检查文件名和路径,确保文件存在并具有正确的读取权限。