AttributeError: 'NoneType' object has no attribute 'unsqueeze'
The quick start code doesn't work. Error is shown as below. BTW, the input image is a 112*112 color person jpg image I found on the Internet.
AttributeError Traceback (most recent call last)
Cell In[3], line 59
57 # KPRPE also takes keypoints locations as input
58 aligner = load_model_by_repo_id('minchul/cvlface_DFA_mobilenet', path, HF_TOKEN)
---> 59 aligned_x, orig_ldmks, aligned_ldmks, score, thetas, bbox = aligner(input)
60 keypoints = orig_ldmks # torch.randn(1, 5, 2)
61 out = model(input, keypoints)
File ~/.local/lib/python3.9/site-packages/torch/nn/modules/module.py:1553, in Module._wrapped_call_impl(self, *args, **kwargs)
1551 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1552 else:
-> 1553 return self._call_impl(*args, **kwargs)
File ~/.local/lib/python3.9/site-packages/torch/nn/modules/module.py:1562, in Module._call_impl(self, *args, **kwargs)
1557 # If we don't have any hooks, we want to skip the rest of the logic in
1558 # this function, and just call forward.
1559 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1560 or _global_backward_pre_hooks or _global_backward_hooks
1561 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1562 return forward_call(*args, **kwargs)
1564 try:
1565 result = None
File ~/.cache/huggingface/modules/transformers_modules/cvlface_adaface_vit_base_kprpe_webface4m/wrapper.py:27, in CVLFaceRecognitionModel.forward(self, *args, **kwargs)
26 def forward(self, *args, **kwargs):
---> 27 return self.model(*args, **kwargs)
File ~/.local/lib/python3.9/site-packages/torch/nn/modules/module.py:1553, in Module._wrapped_call_impl(self, *args, **kwargs)
1551 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1552 else:
-> 1553 return self._call_impl(*args, **kwargs)
File ~/.local/lib/python3.9/site-packages/torch/nn/modules/module.py:1562, in Module._call_impl(self, *args, **kwargs)
1557 # If we don't have any hooks, we want to skip the rest of the logic in
1558 # this function, and just call forward.
1559 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1560 or _global_backward_pre_hooks or _global_backward_hooks
1561 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1562 return forward_call(*args, **kwargs)
1564 try:
1565 result = None
File ~/.cvlface_cache/minchul/cvlface_adaface_vit_base_kprpe_webface4m/models/vit_kprpe/init.py:47, in ViTKPRPEModel.forward(self, x, *args, **kwargs)
45 if self.input_color_flip:
46 x = x.flip(1)
---> 47 return self.net(x, *args, **kwargs)
File ~/.local/lib/python3.9/site-packages/torch/nn/modules/module.py:1553, in Module._wrapped_call_impl(self, *args, **kwargs)
1551 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1552 else:
-> 1553 return self._call_impl(*args, **kwargs)
File ~/.local/lib/python3.9/site-packages/torch/nn/modules/module.py:1562, in Module._call_impl(self, *args, **kwargs)
1557 # If we don't have any hooks, we want to skip the rest of the logic in
1558 # this function, and just call forward.
1559 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1560 or _global_backward_pre_hooks or _global_backward_hooks
1561 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1562 return forward_call(*args, **kwargs)
1564 try:
1565 result = None
File ~/.cvlface_cache/minchul/cvlface_adaface_vit_base_kprpe_webface4m/models/vit_kprpe/vit.py:310, in VisionTransformerWithKPRPE.forward(self, x, keypoints)
309 def forward(self, x, keypoints=None):
--> 310 x = self.forward_features(x, keypoints=keypoints)
311 x = self.feature(x)
312 return x
File ~/.cvlface_cache/minchul/cvlface_adaface_vit_base_kprpe_webface4m/models/vit_kprpe/vit.py:288, in VisionTransformerWithKPRPE.forward_features(self, x, keypoints)
285 if self.training and self.mask_ratio > 0:
286 x, _, ids_restore = self.random_masking(x)
--> 288 extra_ctx = make_kprpe_input(keypoints, x, self.keypoint_linear, self.rpe_config, self.mask_ratio,
289 self.depth, self.num_heads, self.num_buckets)
291 for block_idx, func in enumerate(self.blocks):
292 if isinstance(extra_ctx, list):
File ~/.cvlface_cache/minchul/cvlface_adaface_vit_base_kprpe_webface4m/models/vit_kprpe/rpe_options.py:109, in make_kprpe_input(keypoints, x, keypoint_linear, rpe_config, mask_ratio, depth, num_heads, num_buckets)
107 elif ctx_type == 'rel_keypoint_splithead_unshared':
108 assert mask_ratio == 0
--> 109 rel_keypoints = relative_keypoints.make_rel_keypoints(keypoints, x)[:, :, :2 * num_kp]
110 rel_keypoints = keypoint_linear(rel_keypoints) # B H N D
111 rel_keypoints = rel_keypoints.view(B, -1, num_heads * depth, num_buckets).transpose(1, 2)
File ~/.local/lib/python3.9/site-packages/torch/utils/_contextlib.py:116, in context_decorator..decorate_context(*args, **kwargs)
113 @functools.wraps(func)
114 def decorate_context(*args, **kwargs):
115 with ctx_factory():
--> 116 return func(*args, **kwargs)
File ~/.cvlface_cache/minchul/cvlface_adaface_vit_base_kprpe_webface4m/models/vit_kprpe/RPE/KPRPE/relative_keypoints.py:16, in make_rel_keypoints(keyponints, query)
14 x, y = torch.meshgrid(coord, coord, indexing='ij')
15 grid = torch.stack([y, x], dim=-1).reshape(-1, 2).unsqueeze(0).unsqueeze(-2) # BxNx1x2
---> 16 _keyponints = keyponints.unsqueeze(-3) # Bx1x5x2
17 diff = (grid - _keyponints) # BxNx5x2
18 diff = diff.flatten(2) # BxNx10
AttributeError: 'NoneType' object has no attribute 'unsqueeze'
1