From c4a72b568503c74626b68bc7988d0c921379165c Mon Sep 17 00:00:00 2001 From: Rosie Wood Date: Fri, 22 May 2026 14:07:58 +0000 Subject: [PATCH 1/8] update dependencies --- mapreader/annotate/annotator.py | 4 ++-- mapreader/classify/classifier.py | 2 +- mapreader/classify/load_annotations.py | 2 +- mapreader/download/sheet_downloader.py | 2 +- mapreader/load/images.py | 2 +- mapreader/process/occlusion_analysis.py | 4 ++-- setup.py | 28 ++++++++++++------------- tests/test_classify/test_classifier.py | 8 +++---- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/mapreader/annotate/annotator.py b/mapreader/annotate/annotator.py index 4f2a80f6..0dcb1e6f 100644 --- a/mapreader/annotate/annotator.py +++ b/mapreader/annotate/annotator.py @@ -477,7 +477,7 @@ def _get_queue( """ def check_eligibility(row): - if row.label not in [np.NaN, None]: + if row.label not in [np.nan, None]: return False if self._filter_for is None: @@ -546,7 +546,7 @@ def get_square(image_path, dim=True, border=False): # Dim the image if dim in ["True", True]: - im_array = np.array(im) + im_array = np.array(im, dtype=np.float32) im_array = 256 - (256 - im_array) * 0.4 # lighten image im = Image.fromarray(im_array.astype(np.uint8)) diff --git a/mapreader/classify/classifier.py b/mapreader/classify/classifier.py index 5be5a6cd..f4b9d3e3 100644 --- a/mapreader/classify/classifier.py +++ b/mapreader/classify/classifier.py @@ -1770,7 +1770,7 @@ def load( par_name = os.path.dirname(load_path) base_name = os.path.basename(load_path) path2model = os.path.join(par_name, f"model_{base_name}") - self.model = torch.load(path2model, map_location=mydevice) + self.model = torch.load(path2model, map_location=mydevice, weights_only=False) try: self.device = mydevice diff --git a/mapreader/classify/load_annotations.py b/mapreader/classify/load_annotations.py index c8ea3d70..90f16741 100644 --- a/mapreader/classify/load_annotations.py +++ b/mapreader/classify/load_annotations.py @@ -869,7 +869,7 @@ def _define_sampler(self): value_counts = ( datasets["train"].patch_df[self.label_col].value_counts().to_list() ) - weights = np.reciprocal(Tensor(value_counts)) + weights = Tensor(value_counts).reciprocal() weights = weights.double() sampler = WeightedRandomSampler( weights[datasets["train"].patch_df["label_index"].tolist()], diff --git a/mapreader/download/sheet_downloader.py b/mapreader/download/sheet_downloader.py index fc277f1f..3f7150c1 100644 --- a/mapreader/download/sheet_downloader.py +++ b/mapreader/download/sheet_downloader.py @@ -170,7 +170,7 @@ def get_merged_polygon(self) -> None: """ Creates a multipolygon representing all maps in metadata. """ - self.merged_polygon = self.metadata["geometry"].unary_union + self.merged_polygon = self.metadata["geometry"].union_all() def get_minmax_latlon(self) -> None: """ diff --git a/mapreader/load/images.py b/mapreader/load/images.py index 71bc1c7e..e6e116d6 100644 --- a/mapreader/load/images.py +++ b/mapreader/load/images.py @@ -897,7 +897,7 @@ def _infer_parent_coords_from_patches_id( self._add_patch_coords_id(patch_id, verbose) if isinstance(patch_df, gpd.GeoDataFrame): - parent_polygon = patch_df.unary_union + parent_polygon = patch_df.union_all() parent_coords = parent_polygon.bounds self.parents[image_id]["coordinates"] = parent_coords diff --git a/mapreader/process/occlusion_analysis.py b/mapreader/process/occlusion_analysis.py index c91ab342..9fb01bff 100644 --- a/mapreader/process/occlusion_analysis.py +++ b/mapreader/process/occlusion_analysis.py @@ -110,7 +110,7 @@ def __len__(self): return len(self.patch_df) def _load_model(self, model_path: str) -> nn.Module: - model = torch.load(model_path, map_location=self.device) + model = torch.load(model_path, map_location=self.device, weights_only=False) return model def add_loss_fn( @@ -284,7 +284,7 @@ def _generate_area_importance_heatmap_with_occlusions( # preprocess the occluded image and get the prediction image_tensor = self._preprocess_image(occluded_image) prediction = self.model(image_tensor) - loss = round(float(self.loss_fn(prediction, gt_prediction)), 4) + loss = round(float(self.loss_fn(prediction, gt_prediction).detach()), 4) # store the loss in the heatmap heatmap[row, column] = loss diff --git a/setup.py b/setup.py index f1219d11..cf871454 100644 --- a/setup.py +++ b/setup.py @@ -29,8 +29,8 @@ python_requires=">=3.9", install_requires=[ "matplotlib>=3.5.0,<4.0.0", - "numpy>=1.21.5,<2.0.0", - "pandas>=2.0.0", + "numpy>=1.21.5,<3.0.0", + "pandas>=2.0.0,<3.0.0", "pyproj>=3.2.0,<4.0.0", "azure-storage-blob>=12.9.0,<13.0.0", "aiohttp>=3.8.1,<4.0.0", @@ -38,41 +38,41 @@ "nest-asyncio>=1.5.1,<2.0.0", "scikit-image>=0.18.3", "scikit-learn>=1.0.1,<2.0.0", - "torch>=1.10.0,<=2.2.2", - "torchvision>=0.11.1,<=0.17.2", + "torch>=1.10.0,<=2.12.0", + "torchvision>=0.11.1,<=0.27.0", "jupyter>=1.0.0,<2.0.0", - "ipykernel>=6.5.1,<7.0.0", + "ipykernel>=6.5.1,<8.0.0", "ipywidgets>=8.0.0,<9.0.0", "ipyannotate==0.1.0-beta.0", - "Cython>=0.29.24,<0.30.0", + "Cython>=0.29.24,<4.0.0", "PyYAML>=6.0,<7.0", "tensorboard>=2.7.0,<3.0.0", "parhugin>=0.0.3,<0.0.4", - "geopy==2.1.0", + "geopy>=2.1.0,<3.0.0", "rasterio>=1.2.10,<2.0.0", "simplekml>=1.3.6,<2.0.0", "versioneer>=0.28", "tqdm<5.0.0", "torchinfo<2.0.0", "openpyxl>=3.1.2,<4.0.0", - "geopandas<1.0.0", + "geopandas<2.0.0", "pyogrio>=0.7.2", "cartopy>=0.22.0", "joblib>=1.4.0", "opencv-python>=4.8.1.78,<5.0.0.0", "folium>=0.12,<1.0.0", "mapclassify>=2.0.0,<3.0.0", - "xyzservices==2024.9.0", + "xyzservices>=2024.9.0", "piffle>=0.7.0", "lxml", ], extras_require={ "dev": [ - "pytest<9.0.0", - "pytest-cov>=4.1.0,<6.0.0", - "timm<1.0.0", - "transformers<4.51.3, !=4.50.0", - "black>=23.7.0,<25.0.0", + "pytest<10.0.0", + "pytest-cov>=4.1.0,<8.0.0", + "timm<2.0.0", + "transformers<5.0.0, !=4.50.0", + "black>=23.7.0,<27.0.0", "flake8>=6.0.0,<8.0.0", ], }, diff --git a/tests/test_classify/test_classifier.py b/tests/test_classify/test_classifier.py index c601dc8e..d962e337 100644 --- a/tests/test_classify/test_classifier.py +++ b/tests/test_classify/test_classifier.py @@ -10,7 +10,7 @@ import torch import transformers from torchvision import models -from transformers import AutoFeatureExtractor, AutoModelForImageClassification +from transformers import AutoImageProcessor, AutoModelForImageClassification from mapreader import AnnotationsLoader, ClassifierContainer from mapreader.classify.datasets import PatchDataset @@ -110,7 +110,7 @@ def test_init_resnet18_torch(inputs): def test_init_resnet18_pickle(inputs, sample_dir): annots, dataloaders = inputs - my_model = torch.load(f"{sample_dir}/model_test.pkl") + my_model = torch.load(f"{sample_dir}/model_test.pkl", weights_only=False) assert isinstance(my_model, models.ResNet) # sanity check classifier = ClassifierContainer( my_model, labels_map=annots.labels_map, dataloaders=dataloaders @@ -128,7 +128,7 @@ def test_init_resnet18_pickle(inputs, sample_dir): @pytest.mark.dependency(name="hf_models", scope="session") def test_init_resnet18_hf(inputs): annots, dataloaders = inputs - AutoFeatureExtractor.from_pretrained("microsoft/resnet-18") + AutoImageProcessor.from_pretrained("microsoft/resnet-18") my_model = AutoModelForImageClassification.from_pretrained("microsoft/resnet-18") model_type = transformers.models.resnet.ResNetForImageClassification assert isinstance(my_model, model_type) # sanity check @@ -387,7 +387,7 @@ def test_infer_models_by_string(inputs, infer_inputs): @pytest.mark.dependency(depends=["hf_models"], scope="session") def test_infer_hf_models(inputs, infer_inputs): annots, dataloaders = inputs - AutoFeatureExtractor.from_pretrained("microsoft/resnet-18") + AutoImageProcessor.from_pretrained("microsoft/resnet-18") my_model = AutoModelForImageClassification.from_pretrained("microsoft/resnet-18") classifier = ClassifierContainer( my_model, labels_map=annots.labels_map, dataloaders=dataloaders From 68d026411aeaec04cd9d8adfe35e63d0ac298663 Mon Sep 17 00:00:00 2001 From: Rosie Wood Date: Fri, 11 Sep 2026 17:33:39 +0100 Subject: [PATCH 2/8] update min transformers version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cf871454..8b4d972b 100644 --- a/setup.py +++ b/setup.py @@ -71,7 +71,7 @@ "pytest<10.0.0", "pytest-cov>=4.1.0,<8.0.0", "timm<2.0.0", - "transformers<5.0.0, !=4.50.0", + "transformers>=4.26.0,<5.0.0,!=4.50.0", "black>=23.7.0,<27.0.0", "flake8>=6.0.0,<8.0.0", ], From a6bb3bf9d08d87b91ca4cbb8de99ad1d1eddd5af Mon Sep 17 00:00:00 2001 From: Rosie Wood Date: Sun, 13 Sep 2026 06:17:12 +0100 Subject: [PATCH 3/8] update actions --- .github/workflows/changelog.yml | 2 +- .github/workflows/dependapot-review.yml | 2 +- .github/workflows/joss-draft-pdf.yml | 4 ++-- .github/workflows/mr_ci.yml | 4 ++-- .github/workflows/mr_ci_text_spotting.yml | 4 ++-- .github/workflows/mr_pip_ci.yml | 4 ++-- .github/workflows/publish-to-conda-forge.yml | 4 ++-- .github/workflows/publish-to-pypi.yml | 4 ++-- .github/workflows/publish-to-test-pypi.yml | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index a23c02c8..d51f2080 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -11,6 +11,6 @@ jobs: name: Check Changelog Action runs-on: ubuntu-latest steps: - - uses: tarides/changelog-check-action@v2 + - uses: tarides/changelog-check-action@v4 with: changelog: CHANGELOG.md diff --git a/.github/workflows/dependapot-review.yml b/.github/workflows/dependapot-review.yml index b9d6d20f..d85f63dd 100644 --- a/.github/workflows/dependapot-review.yml +++ b/.github/workflows/dependapot-review.yml @@ -9,6 +9,6 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: 'Dependency Review' uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/joss-draft-pdf.yml b/.github/workflows/joss-draft-pdf.yml index 76fdc926..12b5227f 100644 --- a/.github/workflows/joss-draft-pdf.yml +++ b/.github/workflows/joss-draft-pdf.yml @@ -6,7 +6,7 @@ jobs: name: Paper Draft steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Build draft PDF uses: openjournals/openjournals-draft-action@master with: @@ -14,7 +14,7 @@ jobs: # This should be the path to the paper within your repo. paper-path: paper/paper.md - name: Upload - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v7 with: name: paper # This is the output path where Pandoc will write the compiled diff --git a/.github/workflows/mr_ci.yml b/.github/workflows/mr_ci.yml index 6d7a72a0..1d3f2123 100644 --- a/.github/workflows/mr_ci.yml +++ b/.github/workflows/mr_ci.yml @@ -21,12 +21,12 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v7 with: fetch-depth: 2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/mr_ci_text_spotting.yml b/.github/workflows/mr_ci_text_spotting.yml index 9bbffc55..929a8eaf 100644 --- a/.github/workflows/mr_ci_text_spotting.yml +++ b/.github/workflows/mr_ci_text_spotting.yml @@ -25,7 +25,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v7 with: fetch-depth: 2 @@ -40,7 +40,7 @@ jobs: df -h - name: Set up Python 3.11 - uses: actions/setup-python@v2 + uses: actions/setup-python@v7 with: python-version: 3.11 diff --git a/.github/workflows/mr_pip_ci.yml b/.github/workflows/mr_pip_ci.yml index 97cd7375..31e9d463 100644 --- a/.github/workflows/mr_pip_ci.yml +++ b/.github/workflows/mr_pip_ci.yml @@ -19,12 +19,12 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v7 with: fetch-depth: 2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/publish-to-conda-forge.yml b/.github/workflows/publish-to-conda-forge.yml index 9b177cc3..1a54a27a 100644 --- a/.github/workflows/publish-to-conda-forge.yml +++ b/.github/workflows/publish-to-conda-forge.yml @@ -26,13 +26,13 @@ jobs: run: shell: bash -l {0} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 with: # Fetch all history so that versioneer can determine the version number fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 0ac400e6..8fde3f47 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -15,11 +15,11 @@ jobs: name: Publish Tagged Python 🐍 distributions 📦 to PyPI runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 with: fetch-depth: 0 - name: Set up Python 3.11 - uses: actions/setup-python@v2 + uses: actions/setup-python@v7 with: python-version: '3.11' - name: Install dependencies diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 98a5d813..2d784330 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -13,11 +13,11 @@ jobs: name: Publish all Python 🐍 distributions 📦 to Test PyPI runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 with: fetch-depth: 0 - name: Set up Python 3.11 - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: python-version: '3.11' - name: Install dependencies From 59547078248654ec2321a1c3a2816dd832bac884 Mon Sep 17 00:00:00 2001 From: Rosie Wood Date: Sun, 13 Sep 2026 06:26:05 +0100 Subject: [PATCH 4/8] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2984d46..d7ddcf39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ _Add new changes here_ ### Fixed - Fixes the `model_summary` method in the `ClassifierContainer` class ([#574](https://github.com/maps-as-data/MapReader/pull/574)) +- Update `AutoFeaturExtractor` to `AutoImageProcessor` to match updated transformers library ([#581](https://github.com/maps-as-data/MapReader/pull/581)) +- Update dependencies ([#581](https://github.com/maps-as-data/MapReader/pull/581)) ## [v1.8.2](https://github.com/Living-with-machines/MapReader/releases/tag/v1.8.2) (2025-12-19) From 2701c92712b9fdccad9231dc0e4d45c7c1ba02d3 Mon Sep 17 00:00:00 2001 From: Rosie Wood Date: Sun, 13 Sep 2026 06:29:41 +0100 Subject: [PATCH 5/8] update min geopandas --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8b4d972b..3ec2c28f 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ "tqdm<5.0.0", "torchinfo<2.0.0", "openpyxl>=3.1.2,<4.0.0", - "geopandas<2.0.0", + "geopandas>=1.0.0,<2.0.0", "pyogrio>=0.7.2", "cartopy>=0.22.0", "joblib>=1.4.0", From 99c6b84a78e798d99342a6bf33542ca369be332f Mon Sep 17 00:00:00 2001 From: Rosie Wood Date: Sun, 13 Sep 2026 06:48:20 +0100 Subject: [PATCH 6/8] update hf install in github workflow --- .github/workflows/mr_ci_text_spotting.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mr_ci_text_spotting.yml b/.github/workflows/mr_ci_text_spotting.yml index 929a8eaf..da033aef 100644 --- a/.github/workflows/mr_ci_text_spotting.yml +++ b/.github/workflows/mr_ci_text_spotting.yml @@ -79,10 +79,10 @@ jobs: - name: Hugging Face CLI run: | - pip install -U "huggingface-hub[cli]>=0.30.0,<0.34.0" - huggingface-cli download rwood-97/DPText_DETR_ArT_R_50_poly art_final.pth --local-dir . - huggingface-cli download rwood-97/DeepSolo_ic15_res50 ic15_res50_finetune_synth-tt-mlt-13-15-textocr.pth --local-dir . - huggingface-cli download rwood-97/MapTextPipeline_rumsey rumsey-finetune.pth --local-dir . + pip install -U "huggingface-hub[cli]>=0.34.0,<1.0.0" + hf download rwood-97/DPText_DETR_ArT_R_50_poly art_final.pth --local-dir . + hf download rwood-97/DeepSolo_ic15_res50 ic15_res50_finetune_synth-tt-mlt-13-15-textocr.pth --local-dir . + hf download rwood-97/MapTextPipeline_rumsey rumsey-finetune.pth --local-dir . - name: Test with pytest run: | From 8daee28aff7944d3740f70be4dc866c5f26819f3 Mon Sep 17 00:00:00 2001 From: Rosie Wood Date: Sun, 13 Sep 2026 07:02:37 +0100 Subject: [PATCH 7/8] fix tests --- tests/test_classify/test_classifier.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_classify/test_classifier.py b/tests/test_classify/test_classifier.py index d962e337..2fe95a5b 100644 --- a/tests/test_classify/test_classifier.py +++ b/tests/test_classify/test_classifier.py @@ -22,7 +22,6 @@ def sample_dir(): @pytest.fixture -@pytest.mark.dependency(depends=["load_annots_csv", "dataloaders"], scope="session") def inputs(sample_dir): annots = AnnotationsLoader() annots.load( From 40d5eb6ac5208e9c5c539c3df61b0fb4f279053a Mon Sep 17 00:00:00 2001 From: Rosie Wood Date: Sun, 13 Sep 2026 07:31:47 +0100 Subject: [PATCH 8/8] update torch/torchvision version in ci --- .github/workflows/mr_ci_text_spotting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mr_ci_text_spotting.yml b/.github/workflows/mr_ci_text_spotting.yml index da033aef..d60b8127 100644 --- a/.github/workflows/mr_ci_text_spotting.yml +++ b/.github/workflows/mr_ci_text_spotting.yml @@ -57,7 +57,7 @@ jobs: - name: Install dependencies run: | python -m pip install --no-cache-dir wheel - python -m pip install --no-cache-dir numpy==1.26.4 torch==2.2.2 torchvision==0.17.2 -f https://download.pytorch.org/whl/torch_stable.html + python -m pip install --no-cache-dir numpy==1.26.4 torch==2.12.0 torchvision==0.27.0 -f https://download.pytorch.org/whl/torch_stable.html python -m pip install --no-cache-dir ".[dev]" python -m pip install --no-cache-dir pytest-cov python -m pip install --no-cache-dir --no-build-isolation 'git+https://github.com/facebookresearch/detectron2.git'