Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
153401b
update text spotting and tests with new package names
rwood-97 Oct 22, 2024
fdaa1f0
update CI
rwood-97 Oct 22, 2024
8653909
change import of VitaePredictor
rwood-97 Oct 22, 2024
a3f7186
update tests for get_cfg
rwood-97 Oct 22, 2024
e2320f5
update for linux/windows
rwood-97 Oct 22, 2024
182ba23
check torch installation
rwood-97 Oct 23, 2024
8f04524
remove torch install file path
rwood-97 Oct 23, 2024
fc03781
try with no build isolation
rwood-97 Oct 23, 2024
8789d0c
test with 3.11
rwood-97 Oct 23, 2024
378a05c
simplify install
rwood-97 Oct 23, 2024
ea3d0d8
try with wheel ninja and torch
rwood-97 Oct 23, 2024
47ba521
clean up for windows
rwood-97 Oct 23, 2024
abf2453
download to local dir
rwood-97 Oct 23, 2024
df66889
update text spotting into coverage
rwood-97 Oct 23, 2024
6a14188
ignore text spotting in normal ci
rwood-97 Oct 23, 2024
978b6a0
Update mr_ci_text_spotting to python v2
rwood-97 Oct 23, 2024
92c0623
add text extra to setup.py
rwood-97 Oct 23, 2024
a4de49c
update install in ci text spotting
rwood-97 Oct 23, 2024
b6cd879
update docs
rwood-97 Oct 23, 2024
d24d0bc
update setup.py and ci install
rwood-97 Oct 24, 2024
4cd417e
fix typo
rwood-97 Oct 24, 2024
ed3b5ad
update changelog
rwood-97 Oct 24, 2024
3b038e5
fix install for ci
rwood-97 Oct 24, 2024
381896e
actually fix install for ci
rwood-97 Oct 24, 2024
8e5903c
try remove max path length for windows
rwood-97 Oct 24, 2024
c72766f
try extending max path length with DCMAKE_OBJECT_PATH_MAX=1024
rwood-97 Oct 24, 2024
b980e82
try using winget /apt-get to get ninja
rwood-97 Oct 24, 2024
69ee5b2
use gh action to install ninja
rwood-97 Oct 24, 2024
c52a711
force version to 1.12.1
rwood-97 Oct 24, 2024
50ce991
remove DCMAKE arg
rwood-97 Oct 24, 2024
f78296c
explicitly install detectron2 dptext-detr etc
rwood-97 Oct 24, 2024
4d8f055
Update CHANGELOG.md
rwood-97 Oct 29, 2024
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
3 changes: 2 additions & 1 deletion .github/workflows/mr_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:

- name: Test with pytest
run: |
python -m pytest --cov=./ --cov-report=xml ./tests
python -m pytest ./tests --ignore=tests/test_text_spotting/


- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
98 changes: 45 additions & 53 deletions .github/workflows/mr_ci_text_spotting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@ on: [push]

# Run linter with github actions for quick feedbacks.
jobs:

macos_tests:
runs-on: macos-latest
# run on PRs, or commits to facebookresearch (not internal)
all_tests:
strategy:
fail-fast: false
matrix:
torch: ["1.13.1", "2.2.2"]
include:
- torch: "1.13.1"
torchvision: "0.14.1"
- torch: "2.2.2"
torchvision: "0.17.2"

os: [ubuntu-latest, windows-latest]
fail-fast: false
env:
# point datasets to ~/.torch so it's cached by CI
DETECTRON2_DATASETS: ~/.torch/datasets

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

- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.11

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v5
with:
version: 1.12.1

- name: Update pip
run: |
Expand All @@ -38,52 +37,45 @@ jobs:

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install wheel ninja opencv-python-headless onnx pytest-xdist
python -m pip install numpy==1.26.4
python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
# install from github to get latest; install iopath first since fvcore depends on it
python -m pip install -U 'git+https://github.com/facebookresearch/iopath'
python -m pip install -U 'git+https://github.com/facebookresearch/fvcore'
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
python collect_env.py
python -m pip install wheel
python -m pip install 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 ".[dev]" # not text ones as windows install fails
python -m pip install pytest-cov
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'

- name: Build and install
run: |
CC=clang CXX=clang++ python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
python -m detectron2.utils.collect_env
python -m pip install ".[dev]"

- name: Install DPText-DETR
- name: Clone + install DPText-DETR
run: |
git clone https://github.com/maps-as-data/DPText-DETR.git
python -m pip install 'git+https://github.com/maps-as-data/DPText-DETR.git' # Install DPText-DETR
python -m pip install numpy==1.26.4
wget https://huggingface.co/rwood-97/DPText_DETR_ArT_R_50_poly/resolve/main/art_final.pth

- name: Run DPText-DETR unittests
run: |
python -m pytest test_text_spotting/test_dptext_runner.py

python -m pip install ./DPText-DETR

- name: Install DeepSolo
- name: Clone + install DeepSolo
run: |
git clone https://github.com/maps-as-data/DeepSolo.git
python -m pip install 'git+https://github.com/maps-as-data/DeepSolo.git' --force-reinstall --no-deps # Install DeepSolo
python -m pip install numpy==1.26.4
wget https://huggingface.co/rwood-97/DeepSolo_ic15_res50/resolve/main/ic15_res50_finetune_synth-tt-mlt-13-15-textocr.pth
python -m pip install ./DeepSolo

- name: Run DeepSolo unittests
- name: Clone + install MapTextPipeline
run: |
python -m pytest test_text_spotting/test_deepsolo_runner.py
git clone https://github.com/maps-as-data/MapTextPipeline.git
python -m pip install ./MapTextPipeline

- name: Install MapTextPipeline
- name: Hugging Face CLI
run: |
git clone https://github.com/maps-as-data/MapTextPipeline.git
python -m pip install 'git+https://github.com/maps-as-data/MapTextPipeline.git' --force-reinstall --no-deps # Install MapTextPipeline
python -m pip install "numpy<2.0.0"
wget https://huggingface.co/rwood-97/MapTextPipeline_rumsey/resolve/main/rumsey-finetune.pth
pip install -U "huggingface_hub[cli]"
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 .

- name: Run MapTextPipeline unittests
- name: Test with pytest
run: |
python -m pytest test_text_spotting/test_maptext_runner.py
python -m pytest --cov=./ --cov-report=xml ./tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/reports/
env_vars: OS,PYTHON
fail_ci_if_error: false
files: ./coverage.xml,!./cache
flags: unittests
name: codecov-umbrella
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ The following table shows which versions of MapReader are compatible with which

## Pre-release

_ADD NEW CHANGES HERE_
### Added

- Ability to install all three text-spotting frameworks at same time ([#514](https://github.com/maps-as-data/MapReader/pull/514))
- Can install text spotting dependencies using `pip install mapreader[text]` ([#514](https://github.com/maps-as-data/MapReader/pull/514))
- Text spotting code now covered by tests ([#514](https://github.com/maps-as-data/MapReader/pull/514))

## [v1.4.1](https://github.com/Living-with-machines/MapReader/releases/tag/v1.4.1) (2024-09-17)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,49 @@ Method 1: Install from `PyPI <https://pypi.org/project/mapreader/>`_
If you want to use the latest stable release of MapReader and do not want/need access to the worked examples or MapReader code, we recommend installing from PyPI.
This is probably the easiest way to install MapReader.

- Install ``mapreader``:
To install ``mapreader`` without the text spotting dependencies (i.e. just the classification pipeline):

.. code-block:: bash
.. code-block:: bash

pip install mapreader
pip install mapreader

.. note:: To install the dev dependencies too use ``pip install "mapreader[dev]"`` instead.
Or, to install ``mapreader`` with the text spotting dependencies:

.. code-block:: bash

pip install "mapreader[text]"

.. note:: To install the dev dependencies too use ``pip install "mapreader[dev]"`` or ``pip install "mapreader[text, dev]"``.

Method 2: Install from source
-----------------------------

If you want to keep up with the latest changes to MapReader, or want/need easy access to the worked examples or MapReader code, we reccommend installing from source.
If you want to keep up with the latest changes to MapReader, or want/need easy access to the worked examples or MapReader code, we recommend installing from source.
This method will create a ``MapReader`` directory on your machine which will contain all the MapReader code, docs and worked examples.

.. note:: You will need to have `git <https://git-scm.com/>`__ installed to use this method. If you are using conda, this can be done by running ``conda install git``. Otherwise, you should install git by following the instructions on `their website <https://git-scm.com/book/en/v2/Getting-Started-Installing-Git>`__.

- Clone the ``mapreader`` source code from the `MapReader GitHub repository <https://github.com/Living-with-machines/MapReader>`_:
Clone the ``mapreader`` source code from the `MapReader GitHub repository <https://github.com/Living-with-machines/MapReader>`_:

.. code-block:: bash

git clone https://github.com/Living-with-machines/MapReader.git

Then, to install ``mapreader`` without the text spotting dependencies:

.. code-block:: bash
.. code-block:: bash

git clone https://github.com/Living-with-machines/MapReader.git
cd MapReader
pip install -v -e .

- Install ``mapreader``:
Or, to install ``mapreader`` with the text spotting dependencies:

.. code-block:: bash
.. code-block:: bash

cd MapReader
pip install -v -e .
cd MapReader
pip install -v -e ".[text]"

.. note:: To install the dev dependencies too use ``pip install -v -e ".[dev]"`` instead.
.. note:: To install the dev dependencies too use ``pip install -v -e ".[dev]"`` or ``pip install -v -e ".[text, dev]"``.

..
Method 3: Install via conda (**EXPERIMENTAL**)
Expand Down
22 changes: 12 additions & 10 deletions docs/source/getting-started/troubleshooting-problems.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Troubleshooting
===============

M1 mac
------
numpy/scikit-image issues with M1 mac
-------------------------------------

If you are using an M1 mac and are having issues installing MapReader due to an error when installing numpy or scikit-image:

Expand All @@ -14,17 +14,19 @@ If you are using an M1 mac and are having issues installing MapReader due to an
pip install scikit-image==0.18.3
pip install mapreader

- Try using conda to install the problem packages (edit as needed) and then pip to install MapReader:

.. code-block:: bash

conda install numpy==1.21.5
conda install scikit-image==0.18.3
pip install mapreader

- Alternatively, you can try using a different version of openBLAS when installing:

.. code-block:: bash

brew install openblas
OPENBLAS="$(brew --prefix openblas)" pip install mapreader


detectron2 issues on Windows
----------------------------

If you are having issues installing detectron2 and running a windows machine, please try the following:

- Install `Visual Studio Build Tools <https://visualstudio.microsoft.com/downloads/?q=build+tools>`__.
- Follow instructions `here <https://stackoverflow.com/questions/64261546/how-to-solve-error-microsoft-visual-c-14-0-or-greater-is-required-when-inst>`__ to install the required packages. (The format might be different in newer versions of Visual Studio Build Tools, so you might need to look up the specific package names.
- Once this is done, try rerunning the installation of detectron2 (`pip install "mapreader[text]"`)
82 changes: 10 additions & 72 deletions docs/source/using-mapreader/step-by-step-guide/6-spot-text.rst
Original file line number Diff line number Diff line change
@@ -1,88 +1,26 @@
Spot text
=========

MapReader implements three new frameworks for spotting text on maps:
MapReader implements three frameworks for spotting text on maps:

- ``DPTextDETRRunner`` - This is used to detect text on maps using `DPTextDETR <https://github.com/ymy-k/DPText-DETR/tree/main>`__ and outputs bounding boxes and scores.
- ``DeepSoloRunner`` - This is used to detect and recognize text on maps using `DeepSolo <https://github.com/ViTAE-Transformer/DeepSolo/tree/main>`__ and outputs bounding boxes, text and scores.
- ``MapTextPipeline`` - This is used to detect and recognize text on maps using `MapTextPipeline <https://github.com/yyyyyxie/MapTextPipeline>`__ and outputs bounding boxes, text and scores.

We recommend using the ``MapTextPipeline`` for most use cases as it has been used to train a model on a sample of David Rumsey maps and so should work best for map text spotting.

Install dependencies
--------------------
Installing dependencies
-----------------------

To run text spotting with MapReader, you will need to install the required dependencies. These are listed below:
To run text spotting with MapReader, you will need to install the required dependencies.
Refer to our :doc:`installation instructions </getting-started/installation-instructions/index>` for guidance on how to install these.

.. note:: We have our own forks of the ``DPTextDETRRunner``, ``DeepSolo`` and ``MapTextPipeline`` repos to enable them to work on CPU. Please use our forks but remember to cite the original authors in your work!

Detectron2
~~~~~~~~~~~

Detectron2 is a popular object detection library built by Facebook AI Research.
The main repo is available `here <https://github.com/facebookresearch/detectron2>`__.

To install, run the following commands in your terminal:

.. code:: bash

git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
pip install .


.. admonition:: Detectron2 issues for windows users
:class: dropdown

If you are on a windows machine and are having trouble installing Detectron2, you can try the following:
- Install `Visual Studio Build Tools <https://visualstudio.microsoft.com/downloads/?q=build+tools>`__.
- Follow instructions `here <https://stackoverflow.com/questions/64261546/how-to-solve-error-microsoft-visual-c-14-0-or-greater-is-required-when-inst>`__ to install the required packages. (The format might be different in newer versions of Visual Studio Build Tools, so you might need to look up the specific package names.)

Once this is done, retry installing Detectron2.

You should then **pick one** of the following to install:

.. note:: Since the DPText-DETR, DeepSolo and MapTextPipeline frameworks are built on top of `AdelaiDet <https://github.com/aim-uofa/AdelaiDet>`__, you won't be able to install them at the same. To get around this, you can set up three different conda environments, one for each framework. This will allow you to switch between them as needed.

DPTextDETR
~~~~~~~~~~~

Our fork for DPText-DETR is available `here <https://github.com/rwood-97/DPText-DETR>`__.

To install, run the following commands in your terminal:

.. code:: bash

git clone https://github.com/rwood-97/DPText-DETR.git
cd DPText-DETR
pip install .

DeepSolo
~~~~~~~~

Our fork for DeepSolo is available `here <https://github.com/rwood-97/DeepSolo>`__

To install, run the following commands in your terminal:

.. code:: bash

git clone https://github.com/rwood-97/DeepSolo.git
cd DeepSolo
pip install .

MapTextPipeline
~~~~~~~~~~~~~~~

Our fork for MapTextPipeline is available `here <https://github.com/rwood-97/MapTextPipeline>`__

To install, run the following commands in your terminal:

.. code:: bash

git clone https://github.com/rwood-97/MapTextPipeline.git
cd MapTextPipeline
pip install .
Assuming your installation is successful, you will have installed the following:

- detectron2 - This is a popular object detection library built by Facebook AI Research. The main repo is available `here <https://github.com/facebookresearch/detectron2>`__.
- DPTextDETR - Our fork for DPText-DETR is available `here <https://github.com/rwood-97/DPText-DETR>`__.
- DeepSolo - Our fork for DeepSolo is available `here <https://github.com/rwood-97/DeepSolo>`__
- MapTextPipeline - Our fork for MapTextPipeline is available `here <https://github.com/rwood-97/MapTextPipeline>`__

Advice for patch size
---------------------
Expand Down
22 changes: 8 additions & 14 deletions mapreader/spot_text/deepsolo_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@
import pickle

try:
import adet
from detectron2.engine import DefaultPredictor
except ImportError:
raise ImportError("[ERROR] Please install Detectron2")

try:
import deepsolo # noqa
except ImportError:
raise ImportError(
"[ERROR] Please install DeepSolo from the following link: https://github.com/rwood-97/DeepSolo"
"[ERROR] Please install DeepSolo from the following link: https://github.com/maps-as-data/DeepSolo"
)

import geopandas as gpd
import pandas as pd
import torch
from adet.config import get_cfg

try:
from detectron2.engine import DefaultPredictor
except ImportError:
raise ImportError("[ERROR] Please install Detectron2")

# first assert we are using the deep solo version of adet
if adet.__version__ != "0.2.0-deepsolo":
raise ImportError(
"[ERROR] Please install DeepSolo from the following link: https://github.com/rwood-97/DeepSolo"
)
from deepsolo.config import get_cfg

from .rec_runner_base import RecRunner

Expand Down
Loading