nncf icon indicating copy to clipboard operation
nncf copied to clipboard

AttributeError: 'list' object has no attribute 'keys' when executing yolov8_quantize_with_accuracy_control example

Open openvino-book opened this issue 9 months ago • 1 comments

🐛 Describe the bug

OS = Windows 11 23H2 (22631.3447)

Reproduce the error by following the yolov8_quantize_with_accuracy_control/README.md

git clone https://github.com/openvinotoolkit/nncf.git
cd nncf
pip install .
pip install -r requirements.txt
python main.py

Then get the errro as below:

File "C:\Users\OV\anaconda3\envs\ptq\Lib\site-packages\ultralytics\models\yolo\segment\val.py", line 141, in update_metrics for k in self.stats.keys(): ^^^^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'keys'

1714999187651

Environment

OS = Windows 11 23H2 (22631.3447)

git clone https://github.com/openvinotoolkit/nncf.git
cd nncf
pip install .
pip install -r requirements.txt

Minimal Reproducible Example

No response

Are you going to submit a PR?

  • [ ] Yes I'd like to help by submitting a PR!

openvino-book avatar May 06 '24 12:05 openvino-book

@openvino-book just tested on master branch (commit: cf73597d05a02a947429488ef695c27933879160) and the example is working fine. Please share the commit you used or simply try again using the latest master. If the issue persists, please share the output of pip freeze, your Python* version and the nncf commit used.

image

avitial avatar May 14 '24 19:05 avitial

Had this problem, guess its something with new Yolov8 versions. Fixed this by changing in main.py line 149 from: validator.stats = [] to: validator.stats = dict(tp=[], conf=[], pred_cls=[], target_cls=[])

dxrsgn avatar May 24 '24 01:05 dxrsgn

@openvino-book I followed the instruction yolov8_quantize_with_accuracy_control/README.md and I can't reproduce the issues. I checked both Ubuntu and Windows.

NNCF version: 47187e5bbaef678508fdfdc980b258fc4e32d3db Python: 3.9

I closed the issue. Please feel free to reopen it if it still does not work for you, and share the output of pip freeze, your python version, and the NNCF commit used.

andrey-churkin avatar May 24 '24 07:05 andrey-churkin

@openvino-book I followed the instruction yolov8_quantize_with_accuracy_control/README.md and I can't reproduce the issues. I checked both Ubuntu and Windows.

NNCF version: 47187e5 Python: 3.9

I closed the issue. Please feel free to reopen it if it still does not work for you, and share the output of pip freeze, your python version, and the NNCF commit used.

Hi, @andrey-churkin: Sure! the problem is fixed accroding to the @dxrsgn 's soluiton, to change the L149 to

validator.stats = dict(tp_m=[], tp=[], conf=[], pred_cls=[], target_cls=[])

I has submitted a PR and hope it's helpful.:)

openvino-book avatar May 25 '24 05:05 openvino-book