From 4f664e7c2ef7667f813cc3c8abb6b6ed00dd07d3 Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 19 Oct 2026 10:26:25 +0200 Subject: [PATCH] [models] Switch torch.load to weights_only loading / copy boxes in --- .pre-commit-config.yaml | 2 +- doctr/models/utils/pytorch.py | 2 +- doctr/transforms/functional/base.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5407043a3f..1b702b4795 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: - id: no-commit-to-branch args: ['--branch', 'main'] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.16.10 + rev: v0.17.1 hooks: - id: ruff args: [ --fix ] diff --git a/doctr/models/utils/pytorch.py b/doctr/models/utils/pytorch.py index 3982be3d37..806f3aff00 100644 --- a/doctr/models/utils/pytorch.py +++ b/doctr/models/utils/pytorch.py @@ -70,7 +70,7 @@ def load_pretrained_params( ) # Read state_dict - state_dict = torch.load(archive_path, map_location="cpu") + state_dict = torch.load(archive_path, map_location="cpu", weights_only=True) # Remove weights from the state_dict if ignore_keys is not None and len(ignore_keys) > 0: diff --git a/doctr/transforms/functional/base.py b/doctr/transforms/functional/base.py index 8fc43084b4..f578f0445d 100644 --- a/doctr/transforms/functional/base.py +++ b/doctr/transforms/functional/base.py @@ -25,6 +25,7 @@ def crop_boxes( Returns: the cropped boxes """ + boxes = boxes.copy() is_box_rel = boxes.max() <= 1 is_crop_rel = max(crop_box) <= 1