Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model initialization issue #297

Open
qishisuren123 opened this issue Sep 8, 2024 · 0 comments
Open

Model initialization issue #297

qishisuren123 opened this issue Sep 8, 2024 · 0 comments

Comments

@qishisuren123
Copy link

When I tried to integrate sam2 into another model and initialize the sam2 model within the initialization function of the model class, I encountered the following error.
` def init(self, config, seg_token_idx=None, **kwargs):
super().init(config, **kwargs)

    self.sam2_model = None  
    self.sam2_predictor = None
    self.initialize_sam2()
    
def initialize_sam2(self):
    self.sam2_model = build_sam2(model_cfg, sam2_checkpoint, device='cuda')
    self.sam2_predictor = SAM2ImagePredictor(self.sam2_model)
    `

Traceback (most recent call last): File "my_run.py", line 32, in <module> model = SAM2InternVLChatModel.from_pretrained( File "/anaconda3/envs/internvl/lib/python3.9/site-packages/transformers/modeling_utils.py", line 3594, in from_pretrained model = cls(config, *model_args, **model_kwargs) File "chat.py", line 441, in __init__ self.initialize_sam2() File "chat.py", line 450, in initialize_sam2 self.sam2_model = build_sam2(model_cfg, sam2_checkpoint, device='cuda') File "model/segment-anything-2/sam2/build_sam.py", line 38, in build_sam2 model = model.to(device) File "lib/python3.9/site-packages/torch/nn/modules/module.py", line 1145, in to return self._apply(convert) File "lib/python3.9/site-packages/torch/nn/modules/module.py", line 797, in _apply module._apply(fn) File "lib/python3.9/site-packages/torch/nn/modules/module.py", line 797, in _apply module._apply(fn) File "lib/python3.9/site-packages/torch/nn/modules/module.py", line 797, in _apply module._apply(fn) [Previous line repeated 1 more time] File "lib/python3.9/site-packages/torch/nn/modules/module.py", line 820, in _apply param_applied = fn(param) File "lib/python3.9/site-packages/torch/nn/modules/module.py", line 1143, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) NotImplementedError: Cannot copy out of meta tensor; no data!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant