mapreader 1.3.3__tar.gz → 1.3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {mapreader-1.3.3 → mapreader-1.3.5}/PKG-INFO +45 -50
  2. {mapreader-1.3.3 → mapreader-1.3.5}/README.md +44 -49
  3. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/__init__.py +2 -0
  4. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/_version.py +3 -3
  5. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/annotate/annotator.py +2 -1
  6. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/classify/classifier.py +90 -85
  7. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/classify/datasets.py +120 -120
  8. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/classify/load_annotations.py +18 -6
  9. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/download/downloader.py +42 -2
  10. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/download/sheet_downloader.py +70 -11
  11. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/load/images.py +69 -43
  12. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/load/loader.py +16 -13
  13. mapreader-1.3.5/mapreader/spot_text/deepsolo_runner.py +335 -0
  14. mapreader-1.3.5/mapreader/spot_text/dptext_detr_runner.py +153 -0
  15. mapreader-1.3.3/mapreader/spot_text/dptext_detr_runner.py → mapreader-1.3.5/mapreader/spot_text/runner_base.py +176 -150
  16. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader.egg-info/PKG-INFO +45 -50
  17. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader.egg-info/SOURCES.txt +1 -0
  18. {mapreader-1.3.3 → mapreader-1.3.5}/tests/test_geo_pipeline.py +4 -2
  19. {mapreader-1.3.3 → mapreader-1.3.5}/tests/test_sheet_downloader.py +73 -48
  20. mapreader-1.3.3/mapreader/spot_text/deepsolo_runner.py +0 -643
  21. {mapreader-1.3.3 → mapreader-1.3.5}/LICENSE +0 -0
  22. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/__main__.py +0 -0
  23. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/annotate/__init__.py +0 -0
  24. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/annotate/utils.py +0 -0
  25. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/classify/__init__.py +0 -0
  26. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/classify/custom_models.py +0 -0
  27. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/download/__init__.py +0 -0
  28. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/download/data_structures.py +0 -0
  29. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/download/downloader_utils.py +0 -0
  30. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/download/tile_loading.py +0 -0
  31. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/download/tile_merging.py +0 -0
  32. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/load/__init__.py +0 -0
  33. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/load/geo_utils.py +0 -0
  34. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/process/__init__.py +0 -0
  35. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/process/post_process.py +0 -0
  36. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/process/process.py +0 -0
  37. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/spot_text/__init__.py +0 -0
  38. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/utils/__init__.py +0 -0
  39. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/utils/compute_and_save_stats.py +0 -0
  40. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader/utils/slice_parallel.py +0 -0
  41. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader.egg-info/dependency_links.txt +0 -0
  42. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader.egg-info/entry_points.txt +0 -0
  43. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader.egg-info/not-zip-safe +0 -0
  44. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader.egg-info/requires.txt +0 -0
  45. {mapreader-1.3.3 → mapreader-1.3.5}/mapreader.egg-info/top_level.txt +0 -0
  46. {mapreader-1.3.3 → mapreader-1.3.5}/setup.cfg +0 -0
  47. {mapreader-1.3.3 → mapreader-1.3.5}/setup.py +0 -0
  48. {mapreader-1.3.3 → mapreader-1.3.5}/tests/test_annotator.py +0 -0
  49. {mapreader-1.3.3 → mapreader-1.3.5}/tests/test_import.py +0 -0
  50. {mapreader-1.3.3 → mapreader-1.3.5}/tests/test_post_processing.py +0 -0
  51. {mapreader-1.3.3 → mapreader-1.3.5}/versioneer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mapreader
3
- Version: 1.3.3
3
+ Version: 1.3.5
4
4
  Summary: A computer vision pipeline for the semantic exploration of maps/images at scale
5
5
  Home-page: https://github.com/Living-with-machines/MapReader
6
6
  Download-URL: https://github.com/Living-with-machines/MapReader/archive/refs/heads/main.zip
@@ -66,44 +66,46 @@ Requires-Dist: transformers<5.0.0; extra == "dev"
66
66
  Requires-Dist: black<25.0.0,>=23.7.0; extra == "dev"
67
67
  Requires-Dist: flake8<8.0.0,>=6.0.0; extra == "dev"
68
68
 
69
- <div align="center">
70
- <br>
71
- <p align="center">
72
- <h1>MapReader</h1>
73
- <h2>A computer vision pipeline for exploring and analyzing images at scale</h2>
74
- </p>
75
- </div>
76
-
77
- <p align="center">
78
- <a href="https://pypi.org/project/mapreader/">
79
- <img alt="PyPI" src="https://img.shields.io/pypi/v/MapReader">
80
- </a>
81
- <a href="https://github.com/Living-with-machines/MapReader/blob/main/LICENSE">
82
- <img alt="License" src="https://img.shields.io/badge/License-MIT-yellow.svg">
83
- </a>
84
- <a href="https://github.com/Living-with-machines/MapReader/actions/workflows/mr_ci.yml/badge.svg">
85
- <img alt="Integration Tests badge" src="https://github.com/Living-with-machines/MapReader/actions/workflows/mr_ci.yml/badge.svg">
86
- </a>
87
- <a href="https://zenodo.org/badge/latestdoi/430661738"><img src="https://zenodo.org/badge/430661738.svg" alt="DOI"></a>
88
- <br/>
89
- <a href="https://codecov.io/github/Living-with-machines/MapReader" >
90
- <img src="https://codecov.io/github/Living-with-machines/MapReader/graph/badge.svg?token=38GQ3O1GB5"/>
91
- </a>
92
- </p>
69
+ # MapReader
93
70
 
71
+ > [!IMPORTANT] A computer vision pipeline for exploring and analyzing images at scale
94
72
 
95
- ## What is MapReader?
73
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
74
+ [![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors)
75
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
96
76
 
97
- <div align="center">
98
- <figure>
99
- <img src="https://raw.githubusercontent.com/Living-with-machines/MapReader/main/figs/river_banner_8bit.png"
100
- alt="Annotated Map with Prediction Outputs"
101
- width="70%">
102
- </figure>
103
- </div>
77
+ ![PyPI](https://img.shields.io/pypi/v/MapReader)
78
+ ![License](https://img.shields.io/badge/License-MIT-yellow.svg)
79
+ ![Integration Tests badge](https://github.com/Living-with-machines/MapReader/actions/workflows/mr_ci.yml/badge.svg)
80
+ ![DOI](https://zenodo.org/badge/430661738.svg)
81
+ ![CodeCov](https://codecov.io/github/Living-with-machines/MapReader/graph/badge.svg?token=38GQ3O1GB5)
82
+
83
+ ## Table of Contents
84
+
85
+ - [MapReader](#mapreader)
86
+ - [Table of Contents](#table-of-contents)
87
+ - [What is MapReader?](#what-is-mapreader)
88
+ - [Overview](#overview)
89
+ - [MapReader pipeline](#mapreader-pipeline)
90
+ - [Documentation](#documentation)
91
+ - [What is included in this repo?](#what-is-included-in-this-repo)
92
+ - [How to cite MapReader](#how-to-cite-mapreader)
93
+ - [Acknowledgements](#acknowledgements)
94
+ - [Contributors](#contributors)
95
+
96
+ ---
97
+ <!--- sphinx-include --->
98
+
99
+ ## What is MapReader?
104
100
 
105
101
  MapReader is an end-to-end computer vision (CV) pipeline for exploring and analyzing images at scale.
106
102
 
103
+ <figure align="center">
104
+ <img src="https://raw.githubusercontent.com/Living-with-machines/MapReader/main/docs/source/_static/river_banner_8bit.png"
105
+ alt="Annotated Map with Prediction Outputs"
106
+ width="70%">
107
+ </figure>
108
+
107
109
  MapReader was developed in the [Living with Machines](https://livingwithmachines.ac.uk/) project to analyze large collections of historical maps but is a _**generalizable**_ computer vision pipeline which can be applied to _**any images**_ in a wide variety of domains.
108
110
 
109
111
  ## Overview
@@ -112,30 +114,28 @@ MapReader is a groundbreaking interdisciplinary tool that emerged from a specifi
112
114
 
113
115
  ### MapReader pipeline
114
116
 
115
- <div align="center">
116
- <figure>
117
- <img src="https://raw.githubusercontent.com/Living-with-machines/MapReader/main/docs/source/figures/pipeline_explained.png"
117
+ The MapReader pipeline consists of a linear sequence of tasks which, together, can be used to train a computer vision (CV) classifier to recognize visual features within maps and identify patches containing these features across entire map collections:
118
+
119
+ <figure align="center">
120
+ <img src="https://raw.githubusercontent.com/Living-with-machines/MapReader/main/docs/source/_static/pipeline_explained.png"
118
121
  alt="MapReader pipeline"
119
122
  width="70%">
120
- </figure>
121
- </div>
122
-
123
- The MapReader pipeline consists of a linear sequence of tasks which, together, can be used to train a computer vision (CV) classifier to recognize visual features within maps and identify patches containing these features across entire map collections.
123
+ </figure>
124
124
 
125
- See our [About MapReader](https://mapreader.readthedocs.io/en/latest/About.html) page to learn more.
125
+ See our [Introduction to MapReader](https://mapreader.readthedocs.io/en/latest/introduction-to-mapreader/) page to learn more.
126
126
 
127
127
  ## Documentation
128
128
 
129
- The MapReader documentation can be found at https://mapreader.readthedocs.io/en/latest/index.html.
129
+ The MapReader documentation can be found at https://mapreader.readthedocs.io/en/latest/.
130
130
 
131
- **New users** should refer to the [Installation instructions](https://mapreader.readthedocs.io/en/latest/Install.html) and [Input guidance](https://mapreader.readthedocs.io/en/latest/Input-guidance.html) for help with the initial set up of MapReader.
131
+ **New users** should refer to the [Installation instructions](https://mapreader.readthedocs.io/en/latest/getting-started/installation-instructions/index.html) and [Input guidance](https://mapreader.readthedocs.io/en/latest/using-mapreader/input-guidance/) for help with the initial set up of MapReader.
132
132
 
133
- **All users** should refer to our [User Guide](https://mapreader.readthedocs.io/en/latest/User-guide/User-guide.html) for guidance on how to use MapReader. This contains end-to-end instructions on how to use the MapReader pipeline, plus a number of worked examples illustrating use cases such as:
133
+ **All users** should refer to our [User Guide](https://mapreader.readthedocs.io/en/latest/using-mapreader/) for guidance on how to use MapReader. This contains end-to-end instructions on how to use the MapReader pipeline, plus a number of worked examples illustrating use cases such as:
134
134
 
135
135
  - Geospatial images (i.e. maps)
136
136
  - Non-geospatial images
137
137
 
138
- **Developers and contributors** may also want to refer to the [API documentation](https://mapreader.readthedocs.io/en/latest/api/index.html) and [Contribution guide](https://mapreader.readthedocs.io/en/latest/Contribution-guide/Contribution-guide.html) for guidance on how to contribute to the MapReader package.
138
+ **Developers and contributors** may also want to refer to the [API documentation](https://mapreader.readthedocs.io/en/latest/in-depth-resources/api/mapreader/) and [Contribution guide](https://mapreader.readthedocs.io/en/latest/community-and-contributions/contribution-guide/) for guidance on how to contribute to the MapReader package.
139
139
 
140
140
  **Join our Slack workspace!**
141
141
  Please fill out [this form](https://forms.gle/dXjECHZQkwrZ3Xpt9) to receive an invitation to the Slack workspace.
@@ -163,7 +163,6 @@ If you use MapReader in your work, please cite both the MapReader repo and [our
163
163
  - Kasra Hosseini, Daniel C. S. Wilson, Kaspar Beelen, and Katherine McDonough. 2022. MapReader: a computer vision pipeline for the semantic exploration of maps at scale. In Proceedings of the 6th ACM SIGSPATIAL International Workshop on Geospatial Humanities (GeoHumanities '22). Association for Computing Machinery, New York, NY, USA, 8–19. https://doi.org/10.1145/3557919.3565812
164
164
  - Kasra Hosseini, Rosie Wood, Andy Smith, Katie McDonough, Daniel C.S. Wilson, Christina Last, Kalle Westerling, and Evangeline Mae Corcoran. “Living-with-machines/mapreader: End of Lwm”. Zenodo, July 27, 2023. https://doi.org/10.5281/zenodo.8189653.
165
165
 
166
-
167
166
  ## Acknowledgements
168
167
 
169
168
  This work was supported by Living with Machines (AHRC grant AH/S01179X/1) and The Alan Turing Institute (EPSRC grant EP/N510129/1).
@@ -174,10 +173,6 @@ Maps above reproduced with the permission of the National Library of Scotland ht
174
173
 
175
174
  ## Contributors
176
175
 
177
- <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
178
- [![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-)
179
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
180
-
181
176
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
182
177
  <!-- prettier-ignore-start -->
183
178
  <!-- markdownlint-disable -->
@@ -1,41 +1,43 @@
1
- <div align="center">
2
- <br>
3
- <p align="center">
4
- <h1>MapReader</h1>
5
- <h2>A computer vision pipeline for exploring and analyzing images at scale</h2>
6
- </p>
7
- </div>
8
-
9
- <p align="center">
10
- <a href="https://pypi.org/project/mapreader/">
11
- <img alt="PyPI" src="https://img.shields.io/pypi/v/MapReader">
12
- </a>
13
- <a href="https://github.com/Living-with-machines/MapReader/blob/main/LICENSE">
14
- <img alt="License" src="https://img.shields.io/badge/License-MIT-yellow.svg">
15
- </a>
16
- <a href="https://github.com/Living-with-machines/MapReader/actions/workflows/mr_ci.yml/badge.svg">
17
- <img alt="Integration Tests badge" src="https://github.com/Living-with-machines/MapReader/actions/workflows/mr_ci.yml/badge.svg">
18
- </a>
19
- <a href="https://zenodo.org/badge/latestdoi/430661738"><img src="https://zenodo.org/badge/430661738.svg" alt="DOI"></a>
20
- <br/>
21
- <a href="https://codecov.io/github/Living-with-machines/MapReader" >
22
- <img src="https://codecov.io/github/Living-with-machines/MapReader/graph/badge.svg?token=38GQ3O1GB5"/>
23
- </a>
24
- </p>
1
+ # MapReader
25
2
 
3
+ > [!IMPORTANT] A computer vision pipeline for exploring and analyzing images at scale
26
4
 
27
- ## What is MapReader?
5
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
6
+ [![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors)
7
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
28
8
 
29
- <div align="center">
30
- <figure>
31
- <img src="https://raw.githubusercontent.com/Living-with-machines/MapReader/main/figs/river_banner_8bit.png"
32
- alt="Annotated Map with Prediction Outputs"
33
- width="70%">
34
- </figure>
35
- </div>
9
+ ![PyPI](https://img.shields.io/pypi/v/MapReader)
10
+ ![License](https://img.shields.io/badge/License-MIT-yellow.svg)
11
+ ![Integration Tests badge](https://github.com/Living-with-machines/MapReader/actions/workflows/mr_ci.yml/badge.svg)
12
+ ![DOI](https://zenodo.org/badge/430661738.svg)
13
+ ![CodeCov](https://codecov.io/github/Living-with-machines/MapReader/graph/badge.svg?token=38GQ3O1GB5)
14
+
15
+ ## Table of Contents
16
+
17
+ - [MapReader](#mapreader)
18
+ - [Table of Contents](#table-of-contents)
19
+ - [What is MapReader?](#what-is-mapreader)
20
+ - [Overview](#overview)
21
+ - [MapReader pipeline](#mapreader-pipeline)
22
+ - [Documentation](#documentation)
23
+ - [What is included in this repo?](#what-is-included-in-this-repo)
24
+ - [How to cite MapReader](#how-to-cite-mapreader)
25
+ - [Acknowledgements](#acknowledgements)
26
+ - [Contributors](#contributors)
27
+
28
+ ---
29
+ <!--- sphinx-include --->
30
+
31
+ ## What is MapReader?
36
32
 
37
33
  MapReader is an end-to-end computer vision (CV) pipeline for exploring and analyzing images at scale.
38
34
 
35
+ <figure align="center">
36
+ <img src="https://raw.githubusercontent.com/Living-with-machines/MapReader/main/docs/source/_static/river_banner_8bit.png"
37
+ alt="Annotated Map with Prediction Outputs"
38
+ width="70%">
39
+ </figure>
40
+
39
41
  MapReader was developed in the [Living with Machines](https://livingwithmachines.ac.uk/) project to analyze large collections of historical maps but is a _**generalizable**_ computer vision pipeline which can be applied to _**any images**_ in a wide variety of domains.
40
42
 
41
43
  ## Overview
@@ -44,30 +46,28 @@ MapReader is a groundbreaking interdisciplinary tool that emerged from a specifi
44
46
 
45
47
  ### MapReader pipeline
46
48
 
47
- <div align="center">
48
- <figure>
49
- <img src="https://raw.githubusercontent.com/Living-with-machines/MapReader/main/docs/source/figures/pipeline_explained.png"
49
+ The MapReader pipeline consists of a linear sequence of tasks which, together, can be used to train a computer vision (CV) classifier to recognize visual features within maps and identify patches containing these features across entire map collections:
50
+
51
+ <figure align="center">
52
+ <img src="https://raw.githubusercontent.com/Living-with-machines/MapReader/main/docs/source/_static/pipeline_explained.png"
50
53
  alt="MapReader pipeline"
51
54
  width="70%">
52
- </figure>
53
- </div>
54
-
55
- The MapReader pipeline consists of a linear sequence of tasks which, together, can be used to train a computer vision (CV) classifier to recognize visual features within maps and identify patches containing these features across entire map collections.
55
+ </figure>
56
56
 
57
- See our [About MapReader](https://mapreader.readthedocs.io/en/latest/About.html) page to learn more.
57
+ See our [Introduction to MapReader](https://mapreader.readthedocs.io/en/latest/introduction-to-mapreader/) page to learn more.
58
58
 
59
59
  ## Documentation
60
60
 
61
- The MapReader documentation can be found at https://mapreader.readthedocs.io/en/latest/index.html.
61
+ The MapReader documentation can be found at https://mapreader.readthedocs.io/en/latest/.
62
62
 
63
- **New users** should refer to the [Installation instructions](https://mapreader.readthedocs.io/en/latest/Install.html) and [Input guidance](https://mapreader.readthedocs.io/en/latest/Input-guidance.html) for help with the initial set up of MapReader.
63
+ **New users** should refer to the [Installation instructions](https://mapreader.readthedocs.io/en/latest/getting-started/installation-instructions/index.html) and [Input guidance](https://mapreader.readthedocs.io/en/latest/using-mapreader/input-guidance/) for help with the initial set up of MapReader.
64
64
 
65
- **All users** should refer to our [User Guide](https://mapreader.readthedocs.io/en/latest/User-guide/User-guide.html) for guidance on how to use MapReader. This contains end-to-end instructions on how to use the MapReader pipeline, plus a number of worked examples illustrating use cases such as:
65
+ **All users** should refer to our [User Guide](https://mapreader.readthedocs.io/en/latest/using-mapreader/) for guidance on how to use MapReader. This contains end-to-end instructions on how to use the MapReader pipeline, plus a number of worked examples illustrating use cases such as:
66
66
 
67
67
  - Geospatial images (i.e. maps)
68
68
  - Non-geospatial images
69
69
 
70
- **Developers and contributors** may also want to refer to the [API documentation](https://mapreader.readthedocs.io/en/latest/api/index.html) and [Contribution guide](https://mapreader.readthedocs.io/en/latest/Contribution-guide/Contribution-guide.html) for guidance on how to contribute to the MapReader package.
70
+ **Developers and contributors** may also want to refer to the [API documentation](https://mapreader.readthedocs.io/en/latest/in-depth-resources/api/mapreader/) and [Contribution guide](https://mapreader.readthedocs.io/en/latest/community-and-contributions/contribution-guide/) for guidance on how to contribute to the MapReader package.
71
71
 
72
72
  **Join our Slack workspace!**
73
73
  Please fill out [this form](https://forms.gle/dXjECHZQkwrZ3Xpt9) to receive an invitation to the Slack workspace.
@@ -95,7 +95,6 @@ If you use MapReader in your work, please cite both the MapReader repo and [our
95
95
  - Kasra Hosseini, Daniel C. S. Wilson, Kaspar Beelen, and Katherine McDonough. 2022. MapReader: a computer vision pipeline for the semantic exploration of maps at scale. In Proceedings of the 6th ACM SIGSPATIAL International Workshop on Geospatial Humanities (GeoHumanities '22). Association for Computing Machinery, New York, NY, USA, 8–19. https://doi.org/10.1145/3557919.3565812
96
96
  - Kasra Hosseini, Rosie Wood, Andy Smith, Katie McDonough, Daniel C.S. Wilson, Christina Last, Kalle Westerling, and Evangeline Mae Corcoran. “Living-with-machines/mapreader: End of Lwm”. Zenodo, July 27, 2023. https://doi.org/10.5281/zenodo.8189653.
97
97
 
98
-
99
98
  ## Acknowledgements
100
99
 
101
100
  This work was supported by Living with Machines (AHRC grant AH/S01179X/1) and The Alan Turing Institute (EPSRC grant EP/N510129/1).
@@ -106,10 +105,6 @@ Maps above reproduced with the permission of the National Library of Scotland ht
106
105
 
107
106
  ## Contributors
108
107
 
109
- <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
110
- [![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-)
111
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
112
-
113
108
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
114
109
  <!-- prettier-ignore-start -->
115
110
  <!-- markdownlint-disable -->
@@ -34,5 +34,7 @@ from mapreader.load import geo_utils
34
34
 
35
35
  import mapreader
36
36
 
37
+
37
38
  def print_version():
39
+ """Print the current version of mapreader."""
38
40
  print(mapreader.__version__)
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-07-03T15:08:58+0200",
11
+ "date": "2024-08-02T15:22:56+0100",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "cfc90e76e4e7c3dc58dadf5403a6ef3711d31b08",
15
- "version": "1.3.3"
14
+ "full-revisionid": "49ac0f1daccf0da74b0570db6ade09578debb164",
15
+ "version": "1.3.5"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -680,7 +680,8 @@ class Annotator:
680
680
 
681
681
  Notes
682
682
  -----
683
- This method is a wrapper for the ``_annotate`` method.
683
+ This method is a wrapper for the
684
+ :meth:`~.annotate.annotator.Annotate._annotate` method.
684
685
  """
685
686
  if sortby is not None:
686
687
  self._sortby = sortby
@@ -31,6 +31,77 @@ from .datasets import PatchDataset
31
31
 
32
32
 
33
33
  class ClassifierContainer:
34
+ """
35
+ A class to store and train a PyTorch model.
36
+
37
+ Parameters
38
+ ----------
39
+ model : str, nn.Module or None
40
+ The PyTorch model to add to the object.
41
+
42
+ - If passed as a string, will run ``_initialize_model(model, **kwargs)``. See https://pytorch.org/vision/0.8/models.html for options.
43
+ - Must be ``None`` if ``load_path`` is specified as model will be loaded from file.
44
+
45
+ labels_map: Dict or None
46
+ A dictionary containing the mapping of each label index to its label, with indices as keys and labels as values (i.e. idx: label).
47
+ Can only be ``None`` if ``load_path`` is specified as labels_map will be loaded from file.
48
+ dataloaders: Dict or None
49
+ A dictionary containing set names as keys and dataloaders as values (i.e. set_name: dataloader).
50
+ device : str, optional
51
+ The device to be used for training and storing models.
52
+ Can be set to "default", "cpu", "cuda:0", etc. By default, "default".
53
+ input_size : int, optional
54
+ The expected input size of the model. Default is ``(224,224)``.
55
+ is_inception : bool, optional
56
+ Whether the model is an Inception-style model.
57
+ Default is ``False``.
58
+ load_path : str, optional
59
+ The path to an ``.obj`` file containing a
60
+ force_device : bool, optional
61
+ Whether to force the use of a specific device.
62
+ If set to ``True``, the default device is used.
63
+ Defaults to ``False``.
64
+ kwargs : Dict
65
+ Keyword arguments to pass to the
66
+ :meth:`~.classify.classifier.ClassifierContainer._initialize_model`
67
+ method (if passing ``model`` as a string).
68
+
69
+ Attributes
70
+ ----------
71
+ device : torch.device
72
+ The device being used for training and storing models.
73
+ dataloaders : dict
74
+ A dictionary to store dataloaders for the model.
75
+ labels_map : dict
76
+ A dictionary mapping label indices to their labels.
77
+ dataset_sizes : dict
78
+ A dictionary to store sizes of datasets for the model.
79
+ model : torch.nn.Module
80
+ The model.
81
+ input_size : None or tuple of int
82
+ The size of the input to the model.
83
+ is_inception : bool
84
+ A flag indicating if the model is an Inception model.
85
+ optimizer : None or torch.optim.Optimizer
86
+ The optimizer being used for training the model.
87
+ scheduler : None or torch.optim.lr_scheduler._LRScheduler
88
+ The learning rate scheduler being used for training the model.
89
+ criterion : None or nn.modules.loss._Loss
90
+ The criterion to use for training the model.
91
+ metrics : dict
92
+ A dictionary to store the metrics computed during training.
93
+ last_epoch : int
94
+ The last epoch number completed during training.
95
+ best_loss : torch.Tensor
96
+ The best validation loss achieved during training.
97
+ best_epoch : int
98
+ The epoch in which the best validation loss was achieved during
99
+ training.
100
+ tmp_save_filename : str
101
+ A temporary file name to save checkpoints during training and
102
+ validation.
103
+ """
104
+
34
105
  def __init__(
35
106
  self,
36
107
  model: str | nn.Module | None,
@@ -43,75 +114,6 @@ class ClassifierContainer:
43
114
  force_device: bool | None = False,
44
115
  **kwargs,
45
116
  ):
46
- """
47
- Initialize an ClassifierContainer object.
48
-
49
- Parameters
50
- ----------
51
- model : str, nn.Module or None
52
- The PyTorch model to add to the object.
53
-
54
- - If passed as a string, will run ``_initialize_model(model, **kwargs)``. See https://pytorch.org/vision/0.8/models.html for options.
55
- - Must be ``None`` if ``load_path`` is specified as model will be loaded from file.
56
-
57
- labels_map: Dict or None
58
- A dictionary containing the mapping of each label index to its label, with indices as keys and labels as values (i.e. idx: label).
59
- Can only be ``None`` if ``load_path`` is specified as labels_map will be loaded from file.
60
- dataloaders: Dict or None
61
- A dictionary containing set names as keys and dataloaders as values (i.e. set_name: dataloader).
62
- device : str, optional
63
- The device to be used for training and storing models.
64
- Can be set to "default", "cpu", "cuda:0", etc. By default, "default".
65
- input_size : int, optional
66
- The expected input size of the model. Default is ``(224,224)``.
67
- is_inception : bool, optional
68
- Whether the model is an Inception-style model.
69
- Default is ``False``.
70
- load_path : str, optional
71
- The path to an ``.obj`` file containing a
72
- force_device : bool, optional
73
- Whether to force the use of a specific device.
74
- If set to ``True``, the default device is used.
75
- Defaults to ``False``.
76
- kwargs : Dict
77
- Keyword arguments to pass to the ``_initialize_model()`` method (if passing ``model`` as a string).
78
-
79
- Attributes
80
- ----------
81
- device : torch.device
82
- The device being used for training and storing models.
83
- dataloaders : dict
84
- A dictionary to store dataloaders for the model.
85
- labels_map : dict
86
- A dictionary mapping label indices to their labels.
87
- dataset_sizes : dict
88
- A dictionary to store sizes of datasets for the model.
89
- model : torch.nn.Module
90
- The model.
91
- input_size : None or tuple of int
92
- The size of the input to the model.
93
- is_inception : bool
94
- A flag indicating if the model is an Inception model.
95
- optimizer : None or torch.optim.Optimizer
96
- The optimizer being used for training the model.
97
- scheduler : None or torch.optim.lr_scheduler._LRScheduler
98
- The learning rate scheduler being used for training the model.
99
- criterion : None or nn.modules.loss._Loss
100
- The criterion to use for training the model.
101
- metrics : dict
102
- A dictionary to store the metrics computed during training.
103
- last_epoch : int
104
- The last epoch number completed during training.
105
- best_loss : torch.Tensor
106
- The best validation loss achieved during training.
107
- best_epoch : int
108
- The epoch in which the best validation loss was achieved during
109
- training.
110
- tmp_save_filename : str
111
- A temporary file name to save checkpoints during training and
112
- validation.
113
- """
114
-
115
117
  # set up device
116
118
  if device in ["default", None]:
117
119
  self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
@@ -624,7 +626,7 @@ Use ``initialize_optimizer`` or ``add_optimizer`` to define one." # noqa
624
626
  Notes
625
627
  -----
626
628
  This method calls the
627
- :meth:`mapreader.train.classifier.classifier.train` method with the
629
+ :meth:`~.train.classifier.classifier.train` method with the
628
630
  ``num_epochs`` set to ``1`` and all the other parameters specified in
629
631
  the function arguments.
630
632
  """
@@ -674,7 +676,7 @@ Use ``initialize_optimizer`` or ``add_optimizer`` to define one." # noqa
674
676
  Train the model on the specified phases for a given number of epochs.
675
677
 
676
678
  Wrapper function for
677
- :meth:`mapreader.train.classifier.classifier.train_core` method to
679
+ :meth:`~.train.classifier.classifier.train_core` method to
678
680
  capture exceptions (``KeyboardInterrupt`` is the only supported
679
681
  exception currently).
680
682
 
@@ -716,7 +718,7 @@ Use ``initialize_optimizer`` or ``add_optimizer`` to define one." # noqa
716
718
  Notes
717
719
  -----
718
720
  Refer to the documentation of
719
- :meth:`mapreader.train.classifier.classifier.train_core` for more
721
+ :meth:`~.train.classifier.classifier.train_core` for more
720
722
  information.
721
723
  """
722
724
 
@@ -781,16 +783,19 @@ Use ``initialize_optimizer`` or ``add_optimizer`` to define one." # noqa
781
783
  Raises
782
784
  ------
783
785
  ValueError
784
- If the criterion is not set. Use the ``add_criterion`` method to
785
- set the criterion.
786
+ If the criterion is not set. Use the
787
+ :meth:`~.classify.classifier.ClassifierContainer.add_criterion`
788
+ method to set the criterion.
786
789
 
787
790
  If the optimizer is not set and the phase is "train". Use the
788
- ``initialize_optimizer`` or ``add_optimizer`` method to set the
789
- optimizer.
791
+ :meth:`~.classify.classifier.ClassifierContainer.initialize_optimizer`
792
+ or :meth:`~.classify.classifier.ClassifierContainer.add_optimizer`
793
+ method to set the optimizer.
790
794
 
791
795
  KeyError
792
796
  If the specified phase cannot be found in the keys of the object's
793
- ``dataloaders`` dictionary property.
797
+ :attr:`~.classify.classifier.ClassifierContainer.dataloaders`
798
+ dictionary property.
794
799
 
795
800
  Returns
796
801
  -------
@@ -1102,11 +1107,11 @@ Use ``add_criterion`` to define one."
1102
1107
  Notes
1103
1108
  -----
1104
1109
  This method uses both the
1105
- ``sklearn.metrics.precision_recall_fscore_support`` and
1106
- ``sklearn.metrics.roc_auc_score`` functions from ``scikit-learn`` to
1107
- calculate the metrics for each average type (``"micro"``, ``"macro"``
1108
- and ``"weighted"``). The results are then added to the ``metrics``
1109
- dictionary. It also writes the metrics to the TensorBoard
1110
+ :func:`sklearn.metrics.precision_recall_fscore_support` and
1111
+ :func:`sklearn.metrics.roc_auc_score` functions from ``scikit-learn``
1112
+ to calculate the metrics for each average type (``"micro"``,
1113
+ ``"macro"`` and ``"weighted"``). The results are then added to the
1114
+ ``metrics`` dictionary. It also writes the metrics to the TensorBoard
1110
1115
  SummaryWriter, if ``tboard_writer`` is not None.
1111
1116
  """
1112
1117
  # convert y_score to a numpy array:
@@ -1501,9 +1506,9 @@ Use ``add_criterion`` to define one."
1501
1506
  Notes
1502
1507
  -----
1503
1508
  This method uses the dataloader of the ``ImageClassifierData`` class
1504
- and the ``torchvision.utils.make_grid`` function to display the sample
1505
- data in a grid format. It also calls the ``_imshow`` method of the
1506
- ``ImageClassifierData`` class to show the sample data.
1509
+ and the :func:`torchvision.utils.make_grid` function to display the
1510
+ sample data in a grid format. It also calls the ``_imshow`` method of
1511
+ the ``ImageClassifierData`` class to show the sample data.
1507
1512
  """
1508
1513
  if set_name not in self.dataloaders.keys():
1509
1514
  raise ValueError(