cache
CloudCache
Bases: ResultsCache
Cache helper for uploading to cloud storage (GCP). Wraps a normal ResultsCache object and adds methods for uploading/downloading to a bucket directly.
Source code in src/tcd_pipeline/cache/cache.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
clear()
Clears the current cache, deleting the contents of the folder. Does not warn, so be careful about calling this manually or if you've altered the cache folder path.
Source code in src/tcd_pipeline/cache/cache.py
248 249 250 251 252 253 254 255 256 257 |
|
initialise()
Create the cache folder. Optionally clear if this folder is being reused.
Source code in src/tcd_pipeline/cache/cache.py
240 241 242 243 244 245 |
|
save()
abstractmethod
Save the output from a single model pass to the cache.
Source code in src/tcd_pipeline/cache/cache.py
259 260 261 262 263 264 |
|
ResultsCache
Convenience class for storing intermediate results from models. In the case of huge images, it is quite possible that the intermediate results are too large to store in memory. We therefore (by default) cache tiled results as they are generated.
A cache should contain:
- some reference to the source image and the location of the stored results with respect to that image. This is a bounding box in global image coordinates.
- if instance segmentation data: polygons that have been predicted by the model along with classes, detection scores, etc.
- if semantic segmentation data" semantic (confidence) masks corresponding to the predicted tile
Instance segmentation caches return results as ProcessedInstance objects which are then used by the post-processor (or can be inspected directly for debugging).
Source code in src/tcd_pipeline/cache/cache.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
cache_files: list[str]
property
Files stored in the cache folder.
results
property
A list of results that are stored in the cache
__len__()
The length of a cache is defined here as the number of tiles that have been stored in it. It is not necessarily the number of cache files, because for the default cache formats the number of stored files can be very different to the number of tiles saved in them (e.g. 1 for shapefiles, or a few large images for a GeoTIFF cache).
Source code in src/tcd_pipeline/cache/cache.py
177 178 179 180 181 182 183 184 185 |
|
cache_image(image, window)
Stores a geotiff for the tile
Source code in src/tcd_pipeline/cache/cache.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
clear()
Clears the current cache, deleting the contents of the folder. Does not warn, so be careful about calling this manually or if you've altered the cache folder path.
Source code in src/tcd_pipeline/cache/cache.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
initialise()
Create the cache folder.
Source code in src/tcd_pipeline/cache/cache.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
load()
(Re)load the cache, clears the internal results list first.
Source code in src/tcd_pipeline/cache/cache.py
137 138 139 140 141 142 143 144 145 |
|
save()
abstractmethod
Save the output from a single model pass to the cache.
Source code in src/tcd_pipeline/cache/cache.py
93 94 95 96 97 |
|
write_tile_meta(tile_id, bbox, cache_file)
Store metadata for the current tile into the cache folder. This file is then used to determine how many and which tiles have been stored to the cache already.
Source code in src/tcd_pipeline/cache/cache.py
66 67 68 69 70 71 72 73 74 75 |
|