Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 committed Jan 6, 2025
1 parent b149c22 commit e877203
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion onnxtr/models/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _resolve_sub_lines(self, boxes: np.ndarray, word_idcs: list[int]) -> list[li
"""
lines = []
# Sort words horizontally
word_idcs = [word_idcs[idx] for idx in boxes[word_idcs, 0].argsort().tolist()]
word_idcs = [word_idcs[idx] for idx in boxes[word_idcs, 0].argsort().tolist()] # type: ignore[call-overload]

# Eventually split line horizontally
if len(word_idcs) < 2:
Expand Down
2 changes: 1 addition & 1 deletion onnxtr/models/recognition/models/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __call__(self, logits: np.ndarray) -> list[tuple[str, float]]:
"".join(self._embedding[idx] for idx in encoded_seq).split("<eos>")[0] for encoded_seq in out_idxs
]

return list(zip(word_values, np.clip(probs, 0, 1).astype(float).tolist()))
return list(zip(word_values, np.clip(probs, 0, 1).astype(float).tolist())) # type: ignore[arg-type]


def _master(
Expand Down
8 changes: 6 additions & 2 deletions onnxtr/utils/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,13 @@ def draw_boxes(boxes: np.ndarray, image: np.ndarray, color: tuple[int, int, int]
_boxes[:, [1, 3]] *= h
_boxes = _boxes.astype(np.int32)
for box in _boxes.tolist():
xmin, ymin, xmax, ymax = box
xmin, ymin, xmax, ymax = box # type: ignore[misc]
image = cv2.rectangle(
image, (xmin, ymin), (xmax, ymax), color=color if isinstance(color, tuple) else (0, 0, 255), thickness=2
image,
(xmin, ymin),
(xmax, ymax),
color=color if isinstance(color, tuple) else (0, 0, 255),
thickness=2, # type: ignore[arg-type]
)
plt.imshow(image)
plt.plot(**kwargs)

0 comments on commit e877203

Please sign in to comment.