labelImg
labelImg copied to clipboard
Crashes due to unexpected type 'float'
Attempting to zoom via mouse wheel or to draw a bounding box results in an immediate crash. Here's the output when I try to draw a bounding box:
Traceback (most recent call last):
File "/home/stan/.conda/envs/pytorch_cuda3090/lib/python3.10/site-packages/labelImg/labelImg.py", line 1014, in zoom_request
self.add_zoom(scale * units)
File "/home/stan/.conda/envs/pytorch_cuda3090/lib/python3.10/site-packages/labelImg/labelImg.py", line 974, in add_zoom
self.set_zoom(self.zoom_widget.value() + increment)
File "/home/stan/.conda/envs/pytorch_cuda3090/lib/python3.10/site-packages/labelImg/labelImg.py", line 971, in set_zoom
self.zoom_widget.setValue(value)
TypeError: setValue(self, int): argument 1 has unexpected type 'float'
zsh: IOT instruction (core dumped) labelImg
#841 sounds like the same issue.
$ uname -rvsmio
# Linux 5.19.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 29 Aug 2022 15:51:05 +0000 x86_64 unknown GNU/Linux
$ conda list | grep -E '(qt)|(labelimg)'
# labelimg 1.8.6 py310hff52083_1 conda-forge
# pyqt 5.15.7 py310h29803b5_0 conda-forge
# pyqt5-sip 12.11.0 py310hd8f1fbe_0 conda-forge
# qt-main 5.15.4 ha5833f6_2 conda-forge
you need to cast those floats into integer, that helps for me. I had fixes for this issues, but im not able to push it.
You're not supposed to push changes directly but rather to create a pull request by forking (see here).
That aside, do you have more information why this problem surfaces or when it began to surface? Maybe the added context would be helpful for me and others. When I install labelImg via my package manager it works, whereas the installation via conda is broken in the manner described above.
Same issue for me. Downloading the release version for Windows (v1.8.1) worked but the pip install version crashes (v1.8.6).
I think someone needs to release a new version of labelimg with current code. Version 1.8.6 does not contain the fixed code.
Solution. Error in Qt5. float to int conversion Changed: x:\xxxxx\python-310\Lib\site-packages\libs\canvas.py 526 line: default: p.drawRect(left_top.x(), left_top.y(), rect_width), int(rect_height) new: p.drawRect(int(left_top.x()), int(left_top.y()), int(rect_width), int(rect_height)) 530 line: default: p.drawLine( self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height()) new: p.drawLine( int(self.prev_point.x()), 0, int(self.prev_point.x()), int(self.pixmap.height())) 531 line: default: p.drawLine( 0, self.prev_point.y(), self.pixmap.width(), self.prev_point.y()) new: p.drawLine( 0, int(self.prev_point.y()), int(self.pixmap.width()), int(self.prev_point.y())) Changed: x:\xxxxx\python-310\Lib\site-packages\labelImg\labelImg.py 965 line: default: bar.setValue(bar.value() + bar.singleStep() * units) new: bar.setValue(int(bar.value() + bar.singleStep() * units))
Solução. Erro no Qt5. conversão float para int Alterado: x:\xxxxx\python-310\Lib\site-packages\libs\canvas.py 526 linha: padrão: p.drawRect(left_top.x(), left_top.y(), rect_width), int(rect_height) novo: p.drawRect(int(left_top.x()), int(left_top.y()), int(rect_width), int(rect_height)) 530 linha: padrão: p.drawLine( self.prev_point .x(), 0, self.prev_point.x(), self.pixmap.height()) novo: p.drawLine( int(self.prev_point.x()), 0, int(self.prev_point.x( )), int(self.pixmap.height())) 531 linha: padrão: p.drawLine( 0, self.prev_point.y(), self.pixmap.width(), self.prev_point.y()) novo : p.drawLine( 0, int(self.prev_point.y()), int(self.pixmap.width()), int(self.prev_point.y())) Alterado: x:\xxxxx\python-310\ Lib\site-packages\labelImg\labelImg.py 965 linha: padrão: bar.setValue(bar.value() + bar.singleStep() * unidades) novo: bar.setValue(int(bar.value() + bar. singleStep() * unidades))
here it worked, it gave another error, but I used the same logic to fix it - thanks
Thanks @ptiszai after changing those lines now it it working.
thanks @ptiszai,this problem has bothered me for a few days. I successfully solved it using your method.Thank you very much
thanks @ptiszai
Thanks @ptiszai
In x:\xxxxx\python-310\Lib\site-packages\labelImg\labelImg.py
, I got an error at line 971 and I changed :
default :
self.zoom_widget.setValue(value)
new:
self.zoom_widget.setValue(int(value))
Everything worked fine.
Thanks @ptiszai and @p-mathis
I also got crashes today when showing the labels for bounding boxes so had to make the following change in x:\xxxxx\python-310\Lib\site-packages\libs\shape.py
to line 131:
default:
painter.drawText(min_x, min_y, self.label)
new:
painter.drawText(int(min_x), int(min_y), self.label)
Not sure how many people use the feature to display labels on bounding boxes but this fixed things and along with the previous manual updates I'm no longer getting crashes.
Well, why does it work like this? Why can't we draw float values?