bluemellophone commited on
Commit
45d5c5d
·
unverified ·
1 Parent(s): 3d8f931

Updates to tests and documentation for tiles

Browse files
.github/workflows/python-publish.yml CHANGED
@@ -64,6 +64,9 @@ jobs:
64
  test_wheel:
65
  needs: [build_wheels, build_sdist]
66
  runs-on: ubuntu-latest
 
 
 
67
  # upload to PyPI on every tag starting with 'v'
68
  if: github.event_name == 'push' # && startsWith(github.event.ref, 'refs/tags/v')
69
  steps:
 
64
  test_wheel:
65
  needs: [build_wheels, build_sdist]
66
  runs-on: ubuntu-latest
67
+ env:
68
+ WIC_BATCH_SIZE: 16
69
+
70
  # upload to PyPI on every tag starting with 'v'
71
  if: github.event_name == 'push' # && startsWith(github.event.ref, 'refs/tags/v')
72
  steps:
scoutbot/tile/__init__.py CHANGED
@@ -30,8 +30,8 @@ def compute(img_filepath, grid1=True, grid2=True, ext=None, **kwargs):
30
  grid2 (bool, optional): If :obj:`True`, create a secondary dense grid of tiles
31
  on the image with a 50% offset. Defaults to :obj:`True`.
32
  ext (str, optional): The file extension of the resulting tile files. If this value is
33
- not specified, it will use the same extension as `img_filepath`. Defaults
34
- to :obj:`None`.
35
  **kwargs: keyword arguments passed to :meth:`scoutbot.tile.tile_grid`
36
 
37
  Returns:
@@ -93,6 +93,17 @@ def tile_filepath(img_filepath, grid, ext=None):
93
  """
94
  Returns a suggested filepath for a tile given the original image filepath and the tile's grid
95
  coordinates.
 
 
 
 
 
 
 
 
 
 
 
96
  """
97
  x = grid.get('x')
98
  y = grid.get('y')
@@ -116,6 +127,34 @@ def tile_grid(
116
  ):
117
  """
118
  Calculates a grid of tile coordinates for a given image.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  """
120
  h_, w_ = shape[:2]
121
  w, h = size
 
30
  grid2 (bool, optional): If :obj:`True`, create a secondary dense grid of tiles
31
  on the image with a 50% offset. Defaults to :obj:`True`.
32
  ext (str, optional): The file extension of the resulting tile files. If this value is
33
+ not specified, it will use the same extension as `img_filepath`. Passed as input
34
+ to :meth:`scoutbot.tile.tile_filepath`. Defaults to :obj:`None`.
35
  **kwargs: keyword arguments passed to :meth:`scoutbot.tile.tile_grid`
36
 
37
  Returns:
 
93
  """
94
  Returns a suggested filepath for a tile given the original image filepath and the tile's grid
95
  coordinates.
96
+
97
+ Args:
98
+ img_filepath (str): image filepath (relative or absolute)
99
+ grid (dict): a dictionary of one grid coordinate, one output of
100
+ :meth:`scoutbot.tile.tile_grid`
101
+ ext (str, optional): The file extension of the resulting tile files. If this value is
102
+ not specified, it will use the same extension as `img_filepath`. Defaults
103
+ to :obj:`None`.
104
+
105
+ Returns:
106
+ str: the suggested absolute filepath to store the tile
107
  """
108
  x = grid.get('x')
109
  y = grid.get('y')
 
127
  ):
128
  """
129
  Calculates a grid of tile coordinates for a given image.
130
+
131
+ The final output is a list of lists of dictionaries, each representing a single
132
+ tile coordinate. Each dictionary has a structure with the following keys:
133
+
134
+ ::
135
+
136
+ {
137
+ 'x': x_top_left (int)
138
+ 'y': y_top_left (int)
139
+ 'w': width (int)
140
+ 'h': height (int)
141
+ 'b': border (bool)
142
+ }
143
+
144
+ The ``x``, ``y``, ``w``, ``h`` bounding box keys are in real pixel values.
145
+
146
+ The ``b`` key is :obj:`True` if the grid coordinate is on the border of the image.
147
+
148
+ Args:
149
+ shape (tuple): the image's shape as ``(h, w, c)`` or ``(h, w)``
150
+ size (tuple): the tile's shape as ``(w, h)``
151
+ overlap (int): The amount of pixel overlap between each tile, for both the x-axis
152
+ and the y-axis.
153
+ offset (int): The amount of pixel offset for the entire grid
154
+ borders (bool): If :obj:`True`, include a set of border-only tiles. Defaults to :obj:`True`.
155
+
156
+ Returns:
157
+ list ( dict ): a list of grid coordinate dictionaries
158
  """
159
  h_, w_ = shape[:2]
160
  w, h = size