(fig, image_path, dest_folder, belongs_to_train)
| 256 | |
| 257 | |
| 258 | def save_labeled_frame(fig, image_path, dest_folder, belongs_to_train): |
| 259 | path = Path(image_path) |
| 260 | imagename = path.parts[-1] |
| 261 | imfoldername = path.parts[-2] |
| 262 | if belongs_to_train: |
| 263 | dest = "-".join(("Training", imfoldername, imagename)) |
| 264 | else: |
| 265 | dest = "-".join(("Test", imfoldername, imagename)) |
| 266 | full_path = os.path.join(dest_folder, dest) |
| 267 | |
| 268 | # Windows throws error if file path is > 260 characters, can fix with prefix. |
| 269 | # See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation |
| 270 | if len(full_path) >= 260 and os.name == "nt": |
| 271 | full_path = "\\\\?\\" + full_path |
| 272 | fig.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0) |
| 273 | fig.savefig(full_path) |
| 274 | |
| 275 | |
| 276 | def create_minimal_figure(dpi=100): |
no outgoing calls
no test coverage detected