1、anconda安裝python、qt的版本
conda create -n labelme python==3.10.18
PyQt5 5.15.11 <pip>
PyQt5-Qt5 5.15.2 <pip>
PyQt5_sip 12.17.0 <pip>
2、安裝labelimg
https://github.com/HumanSignal/labelImg
tag選擇:v1.8.6版本(最好選擇)
conda install pyqt=5
conda install -c anaconda lxml
pyrcc5 -o libs/resources.py resources.qrc
python labelImg.py
python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]
3、設置predefined_classes文件,然后進行替換(在./data/predefined_classes.txt,yolo格式需要)
scrapingNozzle
black
white
impurityOthers
filiform
4、出現點擊繪制出錯進行修改
p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height())
TypeError: arguments did not match any overloaded call:drawLine(self, l: QLineF): argument 1 has unexpected type 'float'drawLine(self, line: QLine): argument 1 has unexpected type 'float'drawLine(self, x1: int, y1: int, x2: int, y2: int): argument 1 has unexpected type 'float'drawLine(self, p1: QPoint, p2: QPoint): argument 1 has unexpected type 'float'drawLine(self, p1: Union[QPointF, QPoint], p2: Union[QPointF, QPoint]): argument 1 has unexpected type 'float'
4.1 打開canvas.py文件
# 526行p.drawRect(left_top.x(), left_top.y(), rect_width, rect_height)修改為p.drawRect(int(left_top.x()),int(left_top.y()), int(rect_width), int(rect_height))#530行
p.drawLine(self.prev_point.x(), 0, self.prev_point.x(), self.pixmap.height())
修改為
p.drawLine(int(self.prev_point.x()), 0, int(self.prev_point.x()), int(self.pixmap.height()))#531行p.drawLine(0, self.prev_point.y(),self.pixmap.width(), self.prev_point.y())
修改為p.drawLine(0, int(self.prev_point.y()),int( self.pixmap.width()), int(self.prev_point.y()))
4.2 打開labelImg.py
#965行
bar.setValue(bar.value() + bar.singleStep() * units)
修改為
bar.setValue(int(bar.value() + bar.singleStep() * units))