Skip to content

[bug] Node: ImageBiRefNetMatting fails #2822

@natowi

Description

@natowi

Describe the bug
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\user\weights/cv\swin_large_patch4_window12_384_22kto1k.pth'

after I downloaded the model Download the model from https://huggingface.co/ViperYX/BiRefNet/blob/main/swin_large_patch4_window12_384_22kto1k.pth and put it into the location
I got a new error:
An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

To Reproduce

Image

Expected behavior
Do not fall back to a path in the user directory. Allow to specify the path to the model in the node settings.

Log 1
[info] Chunk range from 0 to 1 info:ImageBiRefNetMatting_1:Chunk range from 0 to 1 INFO:root: - elapsed time: 0:01:14.762045 Traceback (most recent call last): File "C:\Release\sources\Meshroom\venv\Lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 140, in run File "C:\Release\sources\Meshroom\setupInitScriptWindows.py", line 34, in run File "bin\meshroom_compute", line 103, in <module> File "C:\Release\sources\Meshroom\meshroom\core\node.py", line 1277, in process File "C:\Release\sources\Meshroom\meshroom\core\node.py", line 502, in process File "E:\Meshroom-2025.1.0-Windows\Meshroom-2025.1.0\plugins\mrSegmentation\meshroom\imageSegmentation\ImageBiRefNetMatting.py", line 177, in processChunk processor = segmentation.BiRefNetSeg(modelType = chunk.node.birefnetModelType.value, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows\Meshroom-2025.1.0\plugins\mrSegmentation\segmentationRDS\segmentation.py", line 421, in __init__ self.brn = BiRefNet.from_pretrained(pretrainedModel) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\hub_mixin.py", line 566, in from_pretrained instance = cls._from_pretrained( ^^^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\hub_mixin.py", line 789, in _from_pretrained model = cls(**model_kwargs) ^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\birefnet\models\birefnet.py", line 41, in __init__ self.bb = build_backbone(self.config.bb, pretrained=bb_pretrained) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\birefnet\models\backbones\build_backbone.py", line 25, in build_backbone bb = load_weights(bb, bb_name) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\birefnet\models\backbones\build_backbone.py", line 29, in load_weights save_model = torch.load(config.weights[model_name], map_location='cpu', weights_only=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\torch\serialization.py", line 1319, in load with _open_file_like(f, "rb") as opened_file: ^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\torch\serialization.py", line 659, in _open_file_like return _open_file(name_or_buffer, mode) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\torch\serialization.py", line 640, in __init__ super().__init__(open(name, mode)) ^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\weights/cv\\swin_large_patch4_window12_384_22kto1k.pth' Exception ignored in: <function BiRefNetSeg.__del__ at 0x000001F4B3477F60> Traceback (most recent call last): File "E:\Meshroom-2025.1.0-Windows\Meshroom-2025.1.0\plugins\mrSegmentation\segmentationRDS\segmentation.py", line 430, in __del__ del self.brn ^^^^^^^^ AttributeError: 'BiRefNetSeg' object has no attribute 'brn'

Log 2

``
[08:53:52.452][info] Chunk range from 0 to 1
info:ImageBiRefNetMatting_1:Chunk range from 0 to 1
INFO:root: - elapsed time: 0:00:11.033889
Traceback (most recent call last):
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1546, in _get_metadata_or_catch_error
metadata = get_hf_file_metadata(
^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1463, in get_hf_file_metadata
r = _request_wrapper(
^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 286, in _request_wrapper
response = _request_wrapper(
^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 309, in _request_wrapper
response = http_backoff(method=method, url=url, **params, retry_on_exceptions=(), retry_on_status_codes=(429,))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils_http.py", line 310, in http_backoff
response = session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils_http.py", line 107, in send
raise OfflineModeIsEnabled(
huggingface_hub.errors.OfflineModeIsEnabled: Cannot reach https://huggingface.co/ZhengPeng7/BiRefNet_HR-matting/resolve/main/model.safetensors: offline mode is enabled. To disable it, please unset the HF_HUB_OFFLINE environment variable.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\hub_mixin.py", line 796, in _from_pretrained
model_file = hf_hub_download(
^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1010, in hf_hub_download
return _hf_hub_download_to_cache_dir(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1117, in _hf_hub_download_to_cache_dir
_raise_on_head_call_error(head_call_error, force_download, local_files_only)
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1661, in _raise_on_head_call_error
raise LocalEntryNotFoundError(
huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1546, in _get_metadata_or_catch_error
metadata = get_hf_file_metadata(
^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1463, in get_hf_file_metadata
r = _request_wrapper(
^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 286, in _request_wrapper
response = _request_wrapper(
^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 309, in _request_wrapper
response = http_backoff(method=method, url=url, **params, retry_on_exceptions=(), retry_on_status_codes=(429,))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils_http.py", line 310, in http_backoff
response = session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils_http.py", line 107, in send
raise OfflineModeIsEnabled(
huggingface_hub.errors.OfflineModeIsEnabled: Cannot reach https://huggingface.co/ZhengPeng7/BiRefNet_HR-matting/resolve/main/pytorch_model.bin: offline mode is enabled. To disable it, please unset the HF_HUB_OFFLINE environment variable.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Release\sources\Meshroom\venv\Lib\site-packages\cx_Freeze\initscripts_startup_.py", line 140, in run
File "C:\Release\sources\Meshroom\setupInitScriptWindows.py", line 34, in run
File "bin\meshroom_compute", line 103, in
File "C:\Release\sources\Meshroom\meshroom\core\node.py", line 1277, in process
File "C:\Release\sources\Meshroom\meshroom\core\node.py", line 502, in process
File "E:\Meshroom-2025.1.0-Windows\Meshroom-2025.1.0\plugins\mrSegmentation\meshroom\imageSegmentation\ImageBiRefNetMatting.py", line 177, in processChunk
processor = segmentation.BiRefNetSeg(modelType = chunk.node.birefnetModelType.value,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows\Meshroom-2025.1.0\plugins\mrSegmentation\segmentationRDS\segmentation.py", line 421, in init
self.brn = BiRefNet.from_pretrained(pretrainedModel)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\hub_mixin.py", line 566, in from_pretrained
instance = cls._from_pretrained(
^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\hub_mixin.py", line 809, in _from_pretrained
model_file = hf_hub_download(
^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\utils_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1010, in hf_hub_download
return _hf_hub_download_to_cache_dir(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1117, in _hf_hub_download_to_cache_dir
_raise_on_head_call_error(head_call_error, force_download, local_files_only)
File "E:\Meshroom-2025.1.0-Windows/Meshroom-2025.1.0/plugins/mrSegmentation/venv/Lib/site-packages\huggingface_hub\file_download.py", line 1661, in _raise_on_head_call_error
raise LocalEntryNotFoundError(
huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.
Found correct weights in the "model" item of loaded state_dict.
Exception ignored in: <function BiRefNetSeg.del at 0x000001C53164F920>
Traceback (most recent call last):
File "E:\Meshroom-2025.1.0-Windows\Meshroom-2025.1.0\plugins\mrSegmentation\segmentationRDS\segmentation.py", line 430, in del
AttributeError: 'BiRefNetSeg' object has no attribute 'brn'
``

Desktop (please complete the following and other pertinent information):

  • OS: win10,
  • Meshroom version: 2025.1 Beta

Metadata

Metadata

Assignees

No one assigned

    Labels

    2025.1bugfor actual bugs (unsure? use type:question)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions