Spaces:
Running
Running
Update inference.py
Browse files- inference.py +2 -5
inference.py
CHANGED
@@ -14,9 +14,8 @@ from face_parsing import init_parser, swap_regions
|
|
14 |
from esrgan.upsample import upscale, load_sr
|
15 |
from basicsr.utils.download_util import load_file_from_url
|
16 |
|
17 |
-
import audio
|
18 |
|
19 |
-
# Оптимизированные импорты: удалены неиспользуемые библиотеки (scipy, json, random, string, glob)
|
20 |
|
21 |
|
22 |
def parse_arguments():
|
@@ -89,7 +88,6 @@ def parse_arguments():
|
|
89 |
|
90 |
args = parser.parse_args()
|
91 |
|
92 |
-
# Определение, является ли ввод статичным изображением
|
93 |
if os.path.isfile(args.face) and os.path.splitext(args.face)[1].lower() in ['.jpg', '.png', '.jpeg']:
|
94 |
args.static = True
|
95 |
|
@@ -117,7 +115,7 @@ def face_detect(detector, images, args):
|
|
117 |
raise RuntimeError('Image too big to run face detection on GPU. Please use the --resize_factor argument')
|
118 |
batch_size //= 2
|
119 |
print(f'Recovering from OOM error; New batch size: {batch_size}')
|
120 |
-
return face_detect(detector, images, args)
|
121 |
|
122 |
results = []
|
123 |
pady1, pady2, padx1, padx2 = args.pads
|
@@ -367,7 +365,6 @@ def main():
|
|
367 |
if out:
|
368 |
out.release()
|
369 |
|
370 |
-
# Определение пути к result.avi
|
371 |
if args.save_as_video:
|
372 |
final_command = f'ffmpeg -y -i "{args.audio}" -i "{result_avi}" -strict -2 -q:v 1 "{args.outfile}"'
|
373 |
subprocess.call(final_command, shell=(platform.system() != 'Windows'))
|
|
|
14 |
from esrgan.upsample import upscale, load_sr
|
15 |
from basicsr.utils.download_util import load_file_from_url
|
16 |
|
17 |
+
import audio
|
18 |
|
|
|
19 |
|
20 |
|
21 |
def parse_arguments():
|
|
|
88 |
|
89 |
args = parser.parse_args()
|
90 |
|
|
|
91 |
if os.path.isfile(args.face) and os.path.splitext(args.face)[1].lower() in ['.jpg', '.png', '.jpeg']:
|
92 |
args.static = True
|
93 |
|
|
|
115 |
raise RuntimeError('Image too big to run face detection on GPU. Please use the --resize_factor argument')
|
116 |
batch_size //= 2
|
117 |
print(f'Recovering from OOM error; New batch size: {batch_size}')
|
118 |
+
return face_detect(detector, images, args)
|
119 |
|
120 |
results = []
|
121 |
pady1, pady2, padx1, padx2 = args.pads
|
|
|
365 |
if out:
|
366 |
out.release()
|
367 |
|
|
|
368 |
if args.save_as_video:
|
369 |
final_command = f'ffmpeg -y -i "{args.audio}" -i "{result_avi}" -strict -2 -q:v 1 "{args.outfile}"'
|
370 |
subprocess.call(final_command, shell=(platform.system() != 'Windows'))
|