Skip to content

convert-annotations

Bases: FileOperation

Source code in file_operations/convert_annotations.py
12
13
14
15
16
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
class ConvertAnnotationsOperation(FileOperation):
    def __init__(self, settings: AppSettings, **kwargs):
        """converts annotation formats from pattern to destination. You Can use only one value of pattern at the time"""
        super().__init__(settings, **kwargs)
        self.destination_type = kwargs.get('destination_type')
        self.converter_mapping = {
            (".xml", "yolo") : VocYOLOConverter
        }
        self.converter = self.converter_mapping[(self.pattern[0], self.destination_type)]()
        self.n_jobs = kwargs.get('n_jobs', 1)


    @staticmethod
    def add_arguments(settings: AppSettings, parser: argparse.ArgumentParser) -> None:
        parser.add_argument(
            Arguments.dst,
            default=None,
            help=HelpStrings.dst
        )
        parser.add_argument(
            Arguments.destination_type,
            help=HelpStrings.destination_type
        )
        parser.add_argument(
            Arguments.n_jobs,
            default=settings.n_jobs,
            help=HelpStrings.n_jobs
        )


    def do_task(self):
        self.converter.convert(self.files_for_task, self.target_directory, self.n_jobs)

__init__(settings, **kwargs)

converts annotation formats from pattern to destination. You Can use only one value of pattern at the time

Source code in file_operations/convert_annotations.py
13
14
15
16
17
18
19
20
21
def __init__(self, settings: AppSettings, **kwargs):
    """converts annotation formats from pattern to destination. You Can use only one value of pattern at the time"""
    super().__init__(settings, **kwargs)
    self.destination_type = kwargs.get('destination_type')
    self.converter_mapping = {
        (".xml", "yolo") : VocYOLOConverter
    }
    self.converter = self.converter_mapping[(self.pattern[0], self.destination_type)]()
    self.n_jobs = kwargs.get('n_jobs', 1)