|
13 | 13 |
|
14 | 14 | from flow_preprocessor.exceptions.exceptions import ParseTextLinesException |
15 | 15 | from flow_preprocessor.utils.logging.preprocessing_logger import logger |
16 | | -# from flow_preprocessor.preprocessing_logic.segmentation import SegmenterYOLO |
17 | 16 |
|
18 | 17 |
|
19 | 18 | # =============================================================================== |
@@ -284,29 +283,35 @@ def parse_xml_file(self, xml_file: str, segment: bool = False) -> None: |
284 | 283 | self.namespace_uri = self.root.tag.split('}')[0][1:] |
285 | 284 | self.namespace = {'prefix': self.namespace_uri} |
286 | 285 | self.xmlns = {'ns': self.namespace_uri} |
287 | | - image_filename = self.get_image_file_name() |
| 286 | + # image_filename = self.get_image_file_name() |
288 | 287 |
|
289 | | - """ |
290 | 288 | if segment: |
291 | 289 | existing_segmentation = self.check_segmentation() |
292 | 290 | if existing_segmentation == 'ground_truth': |
293 | | - pass |
294 | | - else: |
295 | | - segmenter = SegmenterYOLO( |
296 | | - models=['Riksarkivet/yolov9-regions-1', 'Riksarkivet/yolov9-lines-within-regions-1'], |
297 | | - batch_sizes=4, |
298 | | - order_lines=True, |
| 291 | + # If the XML file already contains ground truth segmentation, do not segment again. |
| 292 | + logger.info( |
| 293 | + '%s - XML file %s already contains ground truth segmentation, skipping segmentation.', |
| 294 | + self.__class__.__name__, |
| 295 | + xml_file, |
299 | 296 | ) |
300 | | - self.tree = segmenter.segment(self.tree, image_filename) |
301 | | - self.root = self.tree.getroot() |
302 | | - |
| 297 | + pass |
303 | 298 | elif existing_segmentation == 'segmented': |
304 | | - segmenter = Segmenter('linemasks') |
305 | | - self.root = segmenter.segment(self.root) |
| 299 | + # If the XML file is already segmented, do not segment again - maybe linemasks recognition? |
| 300 | + logger.info( |
| 301 | + '%s - XML file %s is already segmented, skipping segmentation.', |
| 302 | + self.__class__.__name__, |
| 303 | + xml_file, |
| 304 | + ) |
| 305 | + pass |
306 | 306 | else: |
307 | | - segmenter = Segmenter('yolo') |
308 | | - self.root = segmenter.segment(self.root) |
309 | | - """ |
| 307 | + # If the XML file is not segmented, segment it. |
| 308 | + logger.info( |
| 309 | + '%s - XML file %s is not segmented, processing lines.', |
| 310 | + self.__class__.__name__, |
| 311 | + xml_file, |
| 312 | + ) |
| 313 | + pass |
| 314 | + |
310 | 315 |
|
311 | 316 | except (et.XMLSyntaxError, et.ParseError) as e: |
312 | 317 | self.failed_processing.append(xml_file) |
|
0 commit comments