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
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/dependapot-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/joss-draft-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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:
journal: joss
# 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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mr_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/mr_ci_text_spotting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
with:
fetch-depth: 2

Expand All @@ -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

Expand All @@ -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'
Expand All @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mr_pip_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-conda-forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions mapreader/annotate/annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion mapreader/classify/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mapreader/classify/load_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
Expand Down
2 changes: 1 addition & 1 deletion mapreader/download/sheet_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion mapreader/load/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mapreader/process/occlusion_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,50 @@
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",
"Shapely>=2.0.0,<3.0.0",
"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>=1.0.0,<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>=4.26.0,<5.0.0,!=4.50.0",
"black>=23.7.0,<27.0.0",
"flake8>=6.0.0,<8.0.0",
],
},
Expand Down
9 changes: 4 additions & 5 deletions tests/test_classify/test_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -110,7 +109,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
Expand All @@ -128,7 +127,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
Expand Down Expand Up @@ -387,7 +386,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
Expand Down
Loading