File size: 1,515 Bytes
8308bbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
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
import argparse
import os
from utils import crop_face, upscale_image

def parse_args():
    parser = argparse.ArgumentParser(description='Face Enhancement Tool')
    parser.add_argument('--input', type=str, required=True, help='Path to the input image')
    parser.add_argument('--crop', action='store_true', help='Whether to crop the image')
    parser.add_argument('--upscale', action='store_true', help='Whether to upscale the image')
    parser.add_argument('--output', type=str, required=True, help='Path to save the output image')
    args = parser.parse_args()
    
    # Validate input file exists
    if not os.path.exists(args.input):
        parser.error(f"Input file does not exist: {args.input}")
    
    # Validate output directory exists
    output_dir = os.path.dirname(args.output)
    if output_dir and not os.path.exists(output_dir):
        parser.error(f"Output directory does not exist: {output_dir}")
    
    return args

def main():
    args = parse_args()
    print(f"Processing image: {args.input}")
    print(f"Crop enabled: {args.crop}")
    print(f"Upscale enabled: {args.upscale}")
    print(f"Output will be saved to: {args.output}")
    
    face_image = args.input
    if args.crop:
        crop_face(args.input, "./scratch/cropped_face.png")
        face_image = "./scratch/cropped_face.png"

    if args.upscale:
        upscale_image(face_image, "./scratch/upscaled_face.png")
        face_image = "./scratch/upscaled_face.png"
    

    
if __name__ == "__main__":
    main()