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

Can't get attribute 'SPPF' on <module 'models.common' from '/content/zero-shot-object-tracking/models/common.py #21

Open
VYRION-Ai opened this issue Feb 8, 2022 · 4 comments

Comments

@VYRION-Ai
Copy link

i got this error when i run your colab

 File "clip_object_tracker.py", line 360, in <module>
    detect()
  File "clip_object_tracker.py", line 104, in detect
    yolov5_engine = Yolov5Engine(opt.weights, device, opt.classes, opt.confidence, opt.overlap, opt.agnostic_nms, opt.augment, half)
  File "/content/zero-shot-object-tracking/utils/yolov5.py", line 6, in __init__
    self.model = attempt_load(weights, map_location=device)
  File "/content/zero-shot-object-tracking/models/experimental.py", line 118, in attempt_load
    model.append(torch.load(w, map_location=map_location)['model'].float().fuse().eval())  # load FP32 model
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 607, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 882, in _load
    result = unpickler.load()
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 875, in find_class
    return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from '/content/zero-shot-object-tracking/models/common.py'>
@ikitcheng
Copy link

ikitcheng commented Feb 10, 2022

I found this post by programmerah which solved this attribute error.

But now i get another error when I use custom weights:

Namespace(agnostic_nms=False, api_key=None, augment=False, cfg='yolov4.cfg', classes=None, confidence=0.4, detection_engine='yolov5', device='', exist_ok=False, img_size=640, info=False, max_cosine_distance=0.4, name='exp', names='coco.names', nms_max_overlap=1.0, nn_budget=None, overlap=0.3, project='runs/detect', save_conf=False, save_txt=False, source='./data/video/cars.mp4', thickness=3, update=False, url=None, view_img=False, weights=['trial_best.pt'])
Fusing layers... 
Using torch 1.10.0+cu111 CUDA:0 (Tesla K80, 11441.1875MB)

/usr/local/lib/python3.7/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2157.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Traceback (most recent call last):
  File "clip_object_tracker.py", line 360, in <module>
    detect()
  File "clip_object_tracker.py", line 141, in detect
    _ = yolov5_engine.infer(img.half() if half else img) if device.type != 'cpu' else None  # run once
  File "/content/zero-shot-object-tracking/utils/yolov5.py", line 16, in infer
    pred = self.model(img, augment=self.augment)[0]
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/content/zero-shot-object-tracking/models/yolo.py", line 123, in forward
    return self.forward_once(x, profile)  # single-scale inference, train
  File "/content/zero-shot-object-tracking/models/yolo.py", line 139, in forward_once
    x = m(x)  # run
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/content/zero-shot-object-tracking/models/yolo.py", line 58, in forward
    y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i]  # wh
RuntimeError: The size of tensor a (80) must match the size of tensor b (84) at non-singleton dimension 3

@ikitcheng
Copy link

ikitcheng commented Feb 11, 2022

Hi,

Addressing issues #21 and #15.

So I think updating some of the file content with the latest yolov5 repo will solve the problem.

Please see my branch for a fix.

I have tested it in the following notebook, where I commented out the
!git clone https://github.com/roboflow-ai/zero-shot-object-tracking
and replaced it with my version of the repo instead:
!git clone -b fix-custom-weights https://github.com/ikitcheng/zero-shot-object-tracking.git.

To run zeroshot object tracking with custom weights:
!python clip_object_tracker.py --source ./data/video/cars.mp4 --detection-engine yolov5 --weights custom_weights.pt

Please let me know if it works.

Thanks

@AmartyaCSB
Copy link

Hi @ikitcheng

I couldn't see the results being saved at all. Even though the runs are complete, it's a blank folder under exp.
Could you tell me what might be going wrong?

@ikitcheng
Copy link

Hi @AmartyaCSB,
What was your final print statement after executing the cell with
!python clip_object_tracker.py --source ./data/video/cars.mp4 --detection-engine yolov7?

Does it print:

Results saved to runs/detect/exp
Done. (XX.XXXs)

This is the notebook.

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

3 participants