Delete src/anime_super_resolution/old-infer.py
Browse files
src/anime_super_resolution/old-infer.py
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
import sys
|
2 |
-
import os
|
3 |
-
import subprocess
|
4 |
-
import argparse
|
5 |
-
|
6 |
-
# Append the Real-ESRGAN directory to sys.path
|
7 |
-
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'third_party', 'Real-ESRGAN'))
|
8 |
-
|
9 |
-
def infer(args):
|
10 |
-
# Construct the command using parsed arguments
|
11 |
-
cmd = [
|
12 |
-
sys.executable,
|
13 |
-
os.path.join(os.path.dirname(__file__), '..', 'third_party', 'Real-ESRGAN', 'inference_realesrgan.py'),
|
14 |
-
'-n', args.model_name,
|
15 |
-
'-i', args.input_path,
|
16 |
-
'-o', args.output_dir,
|
17 |
-
'--suffix', args.suffix,
|
18 |
-
'--ext', args.ext,
|
19 |
-
'-s', str(args.outscale),
|
20 |
-
'--model_path', args.model_path
|
21 |
-
]
|
22 |
-
|
23 |
-
# Add optional arguments if specified
|
24 |
-
if args.denoise_strength is not None:
|
25 |
-
cmd.extend(['-dn', str(args.denoise_strength)])
|
26 |
-
if args.tile is not None:
|
27 |
-
cmd.extend(['-t', str(args.tile)])
|
28 |
-
if args.tile_pad is not None:
|
29 |
-
cmd.extend(['--tile_pad', str(args.tile_pad)])
|
30 |
-
if args.pre_pad is not None:
|
31 |
-
cmd.extend(['--pre_pad', str(args.pre_pad)])
|
32 |
-
if args.face_enhance:
|
33 |
-
cmd.append('--face_enhance')
|
34 |
-
if args.fp32:
|
35 |
-
cmd.append('--fp32')
|
36 |
-
if args.alpha_upsampler is not None:
|
37 |
-
cmd.extend(['--alpha_upsampler', args.alpha_upsampler])
|
38 |
-
if args.gpu_id is not None:
|
39 |
-
cmd.extend(['-g', str(args.gpu_id)])
|
40 |
-
|
41 |
-
# Run the command
|
42 |
-
subprocess.run(cmd, check=True)
|
43 |
-
|
44 |
-
if __name__ == "__main__":
|
45 |
-
# Set up argument parser
|
46 |
-
parser = argparse.ArgumentParser(description='Run Real-ESRGAN inference for anime super-resolution')
|
47 |
-
parser.add_argument('--model_name', type=str, default='RealESRGAN_x4plus',
|
48 |
-
help='Name of the model to use: RealESRGAN_x4plus | RealESRNet_x4plus | RealESRGAN_x4plus_anime_6B | RealESRGAN_x2plus | realesr-animevideov3 | realesr-general-x4v3')
|
49 |
-
parser.add_argument('--input_path', type=str, default='tests/test_data/input.jpg', help='Path to input image or folder')
|
50 |
-
parser.add_argument('--output_dir', type=str, default='tests/test_data/output', help='Path to output directory')
|
51 |
-
parser.add_argument('--outscale', type=float, default=4, help='Output scale factor')
|
52 |
-
parser.add_argument('--ext', type=str, default='auto', help='Image extension. Options: auto | jpg | png')
|
53 |
-
parser.add_argument('--suffix', type=str, default='out', help='Suffix for output file name')
|
54 |
-
parser.add_argument('--model_path', type=str, default='./ckpts/Real-ESRGAN-Anime-finetuning/net_g_latest.pth',
|
55 |
-
help='Path to model checkpoint')
|
56 |
-
parser.add_argument('--denoise_strength', type=float, default=None,
|
57 |
-
help='Denoise strength (0 to 1). Only used for realesr-general-x4v3 model')
|
58 |
-
parser.add_argument('--tile', type=int, default=None, help='Tile size, 0 for no tile during testing')
|
59 |
-
parser.add_argument('--tile_pad', type=int, default=None, help='Tile padding')
|
60 |
-
parser.add_argument('--pre_pad', type=int, default=None, help='Pre padding size at each border')
|
61 |
-
parser.add_argument('--face_enhance', action='store_true', help='Use GFPGAN to enhance face')
|
62 |
-
parser.add_argument('--fp32', action='store_true', help='Use fp32 precision during inference')
|
63 |
-
parser.add_argument('--alpha_upsampler', type=str, default=None,
|
64 |
-
help='The upsampler for alpha channels. Options: realesrgan | bicubic')
|
65 |
-
parser.add_argument('--gpu_id', type=int, default=None, help='GPU device to use (e.g., 0,1,2 for multi-GPU)')
|
66 |
-
|
67 |
-
# Parse arguments
|
68 |
-
args = parser.parse_args()
|
69 |
-
|
70 |
-
infer(args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|