首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >调用OSError时调用Detectron2LayoutModel

调用OSError时调用Detectron2LayoutModel
EN

Stack Overflow用户
提问于 2022-03-15 13:45:28
回答 1查看 644关注 0票数 2

在Windows中成功安装布局分析器后,将得到以下操作系统错误。

所用代码:

代码语言:javascript
运行
复制
model = lp.Detectron2LayoutModel(config_path="lp://PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/config", 
                                 extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8],
                                 label_map={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"})

使用布局解析器,尝试从图像中提取内容。但是,当我尝试在布局解析器中加载模型时,它会失败,出现以下错误

代码语言:javascript
运行
复制
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_178664\3254664512.py in <module>
      1 model = lp.Detectron2LayoutModel(config_path="lp://PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/config", 
      2                                  extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8],
----> 3                                  label_map={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"})
      4     # Load the deep layout model from the layoutparser API
      5     # For all the supported model, please check the Model

~\Anaconda3\envs\layout\lib\site-packages\layoutparser\models\detectron2\layoutmodel.py in __init__(self, config_path, model_path, label_map, extra_config, enforce_cpu, device)
     89             config_path, model_path, allow_empty_path=True
     90         )
---> 91         config_path = PathManager.get_local_path(config_path)
     92 
     93         if label_map is None:

~\Anaconda3\envs\layout\lib\site-packages\iopath\common\file_io.py in get_local_path(self, path, force, **kwargs)
   1195         handler = self.__get_path_handler(path)  # type: ignore
   1196         try:
-> 1197             bret = handler._get_local_path(path, force=force, **kwargs)
   1198         except TypeError:
   1199             bret = handler._get_local_path(path, **kwargs)

~\Anaconda3\envs\layout\lib\site-packages\layoutparser\models\detectron2\catalog.py in _get_local_path(self, path, **kwargs)
    134         else:
    135             raise ValueError(f"Unknown data_type {data_type}")
--> 136         return PathManager.get_local_path(model_url, **kwargs)
    137 
    138     def _open(self, path, mode="r", **kwargs):

~\Anaconda3\envs\layout\lib\site-packages\iopath\common\file_io.py in get_local_path(self, path, force, **kwargs)
   1195         handler = self.__get_path_handler(path)  # type: ignore
   1196         try:
-> 1197             bret = handler._get_local_path(path, force=force, **kwargs)
   1198         except TypeError:
   1199             bret = handler._get_local_path(path, **kwargs)

~\Anaconda3\envs\layout\lib\site-packages\iopath\common\file_io.py in _get_local_path(self, path, force, cache_dir, **kwargs)
    792 
    793             cached = os.path.join(dirname, filename)
--> 794             with file_lock(cached):
    795                 if not os.path.isfile(cached):
    796                     logger.info("Downloading {} ...".format(path))

~\Anaconda3\envs\layout\lib\site-packages\portalocker\utils.py in __enter__(self)
    155 
    156     def __enter__(self):
--> 157         return self.acquire()
    158 
    159     def __exit__(self,

~\Anaconda3\envs\layout\lib\site-packages\portalocker\utils.py in acquire(self, timeout, check_interval, fail_when_locked)
    237 
    238         # Get a new filehandler
--> 239         fh = self._get_fh()
    240 
    241         def try_close():  # pragma: no cover

~\Anaconda3\envs\layout\lib\site-packages\portalocker\utils.py in _get_fh(self)
    287     def _get_fh(self) -> typing.IO:
    288         '''Get a new filehandle'''
--> 289         return open(self.filename, self.mode, **self.file_open_kwargs)
    290 
    291     def _get_lock(self, fh: typing.IO) -> typing.IO:

OSError: [Errno 22] Invalid argument: 'C:\\Users\\vchinna/.torch/iopath_cache\\s/nau5ut6zgthunil\\config.yaml?dl=1.lock'

不知道是锁还是别的什么。

请帮帮忙

EN

回答 1

Stack Overflow用户

发布于 2022-06-21 09:16:39

甚至我也有类似的错误。我在Windows中手动尝试了一些工作。

我以您的案例为例:'C:\Users\vchinna/.torch/iopath_cache\s/nau5ut6zgthunil\config.yaml?dl=1.lock‘:OSError: Errno 22无效参数

请按照以下程序操作。

导航到C:\Users\vchinna/.torch/iopath_cache\s/nau5ut6zgthunil\config.yaml

  1. 打开config.yaml文件

  1. 滚动到重物:https://www.dropbox.com/s/h7th27jfv19rxiy/model_final.pth?dl=1应该在265线左右。

  1. 复制该链接并将其粘贴到浏览器中,将下载“model_final.pth”。将此文件复制到所需的文件夹。

现在替换权重路径: your_desired_folder/model_final.pth:

  1. 保存它并运行它工作的代码!

但是在你做这件事之前(如果你还没有做),我想周围有一件小工作要做。

https://github.com/Layout-Parser/layout-parser/issues/15 (指向该问题的Github链接)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71483333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档