Skip to content

Yolov12 attribute Error #370

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

Closed
DolapoSalim opened this issue Apr 1, 2025 · 13 comments
Closed

Yolov12 attribute Error #370

DolapoSalim opened this issue Apr 1, 2025 · 13 comments

Comments

@DolapoSalim
Copy link

I tried to run inference on my custom YOLOV12 model but keep running into this error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[7], [line 1](vscode-notebook-cell:?execution_count=7&line=1)
----> [1](vscode-notebook-cell:?execution_count=7&line=1) results = model.predict(image_path)
      [2](vscode-notebook-cell:?execution_count=7&line=2) results[0].show()

File c:\Users\xxxxx\anaconda3\envs\opencv-env\Lib\site-packages\ultralytics\engine\model.py:550, in Model.predict(self, source, stream, predictor, **kwargs)
    [548](file:///C:/Users/xxxx/anaconda3/envs/opencv-env/Lib/site-packages/ultralytics/engine/model.py:548) if prompts and hasattr(self.predictor, "set_prompts"):  # for SAM-type models
    [549](file:///C:/Users/xxx/anaconda3/envs/opencv-env/Lib/site-packages/ultralytics/engine/model.py:549)     self.predictor.set_prompts(prompts)
--> [550](file:///C:/Users/x/axxxnaconda3/envs/opencv-env/Lib/site-packages/ultralytics/engine/model.py:550) return self.predictor.predict_cli(source=source) if is_cli else self.predictor(source=source, stream=stream)

File c:\Users\dolap\anaconda3\envs\opencv-env\Lib\site-packages\ultralytics\engine\predictor.py:214, in BasePredictor.__call__(self, source, model, stream, *args, **kwargs)
    [212](file:///C:/Users/xxx/anaconda3/envs/opencv-env/Lib/site-packages/ultralytics/engine/predictor.py:212)     return self.stream_inference(source, model, *args, **kwargs)
    [213](file:///C:/Users/x/xxanaconda3/envs/opencv-env/Lib/site-packages/ultralytics/engine/predictor.py:213) else:
--> [214](file:///C:/Users/xxx/anaconda3/envs/opencv-env/Lib/site-packages/ultralytics/engine/predictor.py:214)     return list(self.stream_inference(source, model, *args, **kwargs))

File c:\Users\xxxxx\anaconda3\envs\opencv-env\Lib\site-packages\torch\utils\_contextlib.py:36, in _wrap_generator.<locals>.generator_context(*args, **kwargs)
     [33](file:///C:/Users/x/axxxnaconda3/envs/opencv-env/Lib/site-packages/torch/utils/_contextlib.py:33) try:
     [34](file:///C:/Users/xxxx/anaconda3/envs/opencv-env/Lib/site-packages/torch/utils/_contextlib.py:34)     # Issuing `None` to a generator fires it up
     [35](file:///C:/Users/xxx/anaconda3/envs/opencv-env/Lib/site-packages/torch/utils/_contextlib.py:35)     with ctx_factory():
---> [36](file:///C:/Users/xxxx/anaconda3/envs/opencv-env/Lib/site-packages/torch/utils/_contextlib.py:36)         response = gen.send(None)
     [38](file:///C:/Users/xxxxx/anaconda3/envs/opencv-env/Lib/site-packages/torch/utils/_contextlib.py:38)     while True:
     [39](file:///C:/Users/xxxxx/anaconda3/envs/opencv-env/Lib/site-packages/torch/utils/_contextlib.py:39)         try:
     [40](file:///C:/Users/xxxxx/anaconda3/envs/opencv-env/Lib/site-packages/torch/utils/_contextlib.py:40)             # Forward the response to our caller and get its next request
...
-> [1928](file:///C:/Users/x/xxxxanaconda3/envs/opencv-env/Lib/site-packages/torch/nn/modules/module.py:1928) raise AttributeError(
   [1929](file:///C:/Users/xxxxx/anaconda3/envs/opencv-env/Lib/site-packages/torch/nn/modules/module.py:1929)     f"'{type(self).__name__}' object has no attribute '{name}'"
   [1930](file:///C:/Users/xxxxx/anaconda3/envs/opencv-env/Lib/site-packages/torch/nn/modules/module.py:1930) )

AttributeError: 'AAttn' object has no attribute 'qkv'
@miftahurrrizki
Copy link

I have the same problem, have you solved it? 😢

@DolapoSalim
Copy link
Author

I have the same problem, have you solved it? 😢

No, I haven’t

@mortvivant
Copy link

Could anyone solve it ? I have same problem

@panchaldhruv27223
Copy link

!! ALERT ---- URGENT

I ALSO HAVE THE SAME ISSUE.
I HAVE TRIED ALL THE POSSIBLE STEPS TO REOSLVE THIS.
MY MODEL IS LOADING FINE BUT AT THE FINETUNING TIME OR PREDICTION TIME MODEL IS GIVING THIS ERROR.
LAST TIME WHEN I USED IN MARCH MONTH IT IS WORKING FINE BUT NOW MY SCRIPT IS GIVING THIS ERRROR.
CAN ANYONE PLEASED GUIDE ME.

@SkalskiP
Copy link
Collaborator

SkalskiP commented May 5, 2025

@DolapoSalim, @miftahurrrizki, @mortvivant, @panchaldhruv27223 could any of you update installation command to pip install -q git+https://github.com/sunsmarterjie/yolov12.git@3a336a4adf3683d280e1a50d03fa24bbe7f24a5b and check if that solves the issue?

@miftahurrrizki
Copy link

@DolapoSalim, @miftahurrrizki, @mortvivant, @panchaldhruv27223 could any of you update installation command to pip install -q git+https://github.com/sunsmarterjie/yolov12.git@3a336a4adf3683d280e1a50d03fa24bbe7f24a5b and check if that solves the issue?

Thanks, my problem is solved with this!

@DolapoSalim
Copy link
Author

@DolapoSalim, @miftahurrrizki, @mortvivant, @panchaldhruv27223 could any of you update installation command to pip install -q git+https://github.com/sunsmarterjie/yolov12.git@3a336a4adf3683d280e1a50d03fa24bbe7f24a5b and check if that solves the issue?

@SkalskiP Now, the inferencing works fine. Thank you!

@Someet-consuma
Copy link

@DolapoSalim, @miftahurrrizki, @mortvivant, @panchaldhruv27223 could any of you update installation command to pip install -q git+https://github.com/sunsmarterjie/yolov12.git@3a336a4adf3683d280e1a50d03fa24bbe7f24a5b and check if that solves the issue?

Hey i tried this thing but still not able to solve it, getting the same error

@mortvivant
Copy link

@DolapoSalim, @miftahurrrizki, @mortvivant, @panchaldhruv27223 could any of you update installation command to pip install -q git+https://github.com/sunsmarterjie/yolov12.git@3a336a4adf3683d280e1a50d03fa24bbe7f24a5b and check if that solves the issue?

Hey i tried this thing but still not able to solve it, getting the same error

Interesting, when I tried `pip install -q git+https://github.com/sunsmarterjie/yolov12.git@3a336a4adf3683d280e1a50d03fa24bbe7f24a5b'
it works. Are u sure that u trained the model on right way ?

@Someet-consuma
Copy link

Yes I'm able to do the inference also but when i tried to copy the model file put it on different machine, I'm getting the error

@mortvivant
Copy link

Hmm, I'll research for solution, If I can find it , I'll write comment again

@Someet-consuma
Copy link

Thank you

@Andrii0607
Copy link

@Someet-consuma
I had the same problem with you.
As has been mentioned in this issue, probably you used wrong weights for training.
You should not use the "Turbo" version weights. Use the "v1.0" weights instead.

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

7 participants