image_to_image.main

Module to run image-to-image.
Train, test or inference models.

Functions:

  • main

By Tobia Ippolito

 1"""
 2Module to run image-to-image.<br>
 3Train, test or inference models.
 4
 5Functions:
 6- main
 7
 8By Tobia Ippolito
 9"""
10# ---------------------------
11#        > Imports <
12# ---------------------------
13import warnings
14# warnings.filterwarnings("ignore", category=UserWarning, module="pygame")
15warnings.filterwarnings("ignore", category=UserWarning)
16
17from .utils import parse_args
18from .model_interactions import train, inference, test
19
20
21# ---------------------------
22#         > Main <
23# ---------------------------
24def main():
25    """
26    Main entry point for image-to-image tasks.
27
28    This function parses command-line arguments and dispatches
29    the workflow based on the specified mode:
30        - 'train': runs the training routine
31        - 'test': runs evaluation on the test dataset
32        - 'inference': runs inference on images or datasets
33
34    Raises:
35    - ValueError: if the provided mode is unknown.
36    """
37    args = parse_args()
38
39    print(f"Running in mode: {args.mode}")
40    print(f"Using device: {args.device}")
41
42    if args.mode == 'train':
43        train(args)
44    elif args.mode == 'test':
45        test(args)
46    elif args.mode == 'inference':
47        inference(args)
48    else:
49        raise ValueError(f"Unknown mode: {args.mode}")
50
51
52
53if __name__ == '__main__':
54    main()
def main():
25def main():
26    """
27    Main entry point for image-to-image tasks.
28
29    This function parses command-line arguments and dispatches
30    the workflow based on the specified mode:
31        - 'train': runs the training routine
32        - 'test': runs evaluation on the test dataset
33        - 'inference': runs inference on images or datasets
34
35    Raises:
36    - ValueError: if the provided mode is unknown.
37    """
38    args = parse_args()
39
40    print(f"Running in mode: {args.mode}")
41    print(f"Using device: {args.device}")
42
43    if args.mode == 'train':
44        train(args)
45    elif args.mode == 'test':
46        test(args)
47    elif args.mode == 'inference':
48        inference(args)
49    else:
50        raise ValueError(f"Unknown mode: {args.mode}")

Main entry point for image-to-image tasks.

This function parses command-line arguments and dispatches the workflow based on the specified mode: - 'train': runs the training routine - 'test': runs evaluation on the test dataset - 'inference': runs inference on images or datasets

Raises:

  • ValueError: if the provided mode is unknown.