microsoft / microsoft/TRELLIS.2

Tensor.item() cannot be called on meta tensors

Open
#101 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
11.3k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

When I run app.py, this error occurs. What should I do?

File "/projects/github_project/TRELLIS.2/app.py", line 633, in
pipeline = Trellis2ImageTo3DPipeline.from_pretrained('/projects/github_project/TRELLIS.2/models/TRELLIS.2-4B')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/projects/github_project/TRELLIS.2/trellis2/pipelines/trellis2_image_to_3d.py", line 105, in from_pretrained
pipeline.rembg_model = getattr(rembg, args['rembg_model']['name'])(**args['rembg_model']['args'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/projects/github_project/TRELLIS.2/trellis2/pipelines/rembg/BiRefNet.py", line 11, in init
self.model = AutoModelForImageSegmentation.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/projects/github_project/TRELLIS.2/.venv/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py", line 365, in from_pretrained
return model_class.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/projects/github_project/TRELLIS.2/.venv/lib/python3.12/site-packages/transformers/modeling_utils.py", line 4072, in from_pretrained
model = cls(config, *model_args, **model_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jiuzhang/.cache/huggingface/modules/transformers_modules/briaai/birefnet.py", line 1986, in init
self.bb = build_backbone(self.config.bb, pretrained=bb_pretrained)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jiuzhang/.cache/huggingface/modules/transformers_modules/briaai/birefnet.py", line 1405, in build_backbone
bb = eval('{}({})'.format(bb_name, params_settings))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1, in
File "/home/jiuzhang/.cache/huggingface/modules/transformers_modules/briaai/birefnet.py", line 1224, in swin_v1_l
model = SwinTransformer(embed_dim=192, depths=[2, 2, 18, 2], num_heads=[6, 12, 24, 48], window_size=12)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jiuzhang/.cache/huggingface/modules/transformers_modules/briaai/birefnet.py", line 1131, in init
dpr = [x.item() for x in torch.linspace(0, drop_path_rate, sum(depths))] # stochastic depth decay rule
^^^^^^^^
File "/projects/github_project/TRELLIS.2/.venv/lib/python3.12/site-packages/torch/utils/_device.py", line 104, in torch_function
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/projects/github_project/TRELLIS.2/.venv/lib/python3.12/site-packages/torch/_meta_registrations.py", line 6585, in meta_local_scalar_dense
raise RuntimeError("Tensor.item() cannot be called on meta tensors")
RuntimeError: Tensor.item() cannot be called on meta tensors

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at app.py line 633 and trace Trellis2ImageTo3DPipeline.from_pretrained into trellis2/pipelines/trellis2_image_to_3d.py and trellis2/pipelines/rembg/BiRefNet.py. Reproduce the BiRefNet loading failure around the reported Tensor.item() call and determine the project-supported resolution; done means pipeline initialization completes without the meta-tensor error.

Written by the indexing model from the issue text.

Assessment

Tech stack
huggingface, python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.