Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions PPOCRLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,9 @@ def loadFile(self, filePath=None, isAdjustScale=True):

if unicodeFilePath and os.path.exists(unicodeFilePath):
self.canvas.verified = False
cvimg = cv2.imdecode(np.fromfile(unicodeFilePath, dtype=np.uint8), 1)
cvimg = cv2.imdecode(
np.fromfile(unicodeFilePath, dtype=np.uint8), cv2.IMREAD_COLOR
)
height, width, depth = cvimg.shape
cvimg = cv2.cvtColor(cvimg, cv2.COLOR_BGR2RGB)
image = QImage(
Expand Down Expand Up @@ -2939,7 +2941,7 @@ def autoRecognition(self):
self.init_key_list(self.Cachelabel)

def reRecognition(self):
img = cv2.imdecode(np.fromfile(self.filePath, dtype=np.uint8), 1)
img = cv2.imdecode(np.fromfile(self.filePath, dtype=np.uint8), cv2.IMREAD_COLOR)
if self.canvas.shapes:
self.result_dic = []
self.result_dic_locked = (
Expand Down Expand Up @@ -3023,7 +3025,7 @@ def reRecognition(self):
QMessageBox.information(self, "Information", "Draw a box!")

def singleRerecognition(self):
img = cv2.imdecode(np.fromfile(self.filePath, dtype=np.uint8), 1)
img = cv2.imdecode(np.fromfile(self.filePath, dtype=np.uint8), cv2.IMREAD_COLOR)
for shape in self.canvas.selectedShapes:
box = [[int(p.x()), int(p.y())] for p in shape.points]
if len(box) > 4:
Expand Down Expand Up @@ -3495,7 +3497,9 @@ def saveRecResult(self):
idx = self.getImglabelidx(key)
try:
img_path = os.path.dirname(base_dir) + "/" + key
img = cv2.imdecode(np.fromfile(img_path, dtype=np.uint8), -1)
img = cv2.imdecode(
np.fromfile(img_path, dtype=np.uint8), cv2.IMREAD_COLOR
)
for i, label in enumerate(self.PPlabel[idx]):
if label["difficult"]:
continue
Expand Down Expand Up @@ -3645,7 +3649,7 @@ def format_shape(s):
self.actions.save.setEnabled(True)

def expandSelectedShape(self):
img = cv2.imdecode(np.fromfile(self.filePath, dtype=np.uint8), 1)
img = cv2.imdecode(np.fromfile(self.filePath, dtype=np.uint8), cv2.IMREAD_COLOR)
for shape in self.canvas.selectedShapes:
box = [[int(p.x()), int(p.y())] for p in shape.points]
if len(box) > 4:
Expand Down
2 changes: 1 addition & 1 deletion libs/autoDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def run(self):
self.listValue.emit(img_path)
if self.model == "paddle":
h, w, _ = cv2.imdecode(
np.fromfile(img_path, dtype=np.uint8), 1
np.fromfile(img_path, dtype=np.uint8), cv2.IMREAD_COLOR
).shape
if h > 32 and w > 32:
result = self.ocr.predict(img_path)[0]
Expand Down