4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -8,9 +8,9 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Set up Python 3.8
|
- name: Set up Python 3.9
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: 3.9
|
||||||
- run: pip install flake8
|
- run: pip install flake8
|
||||||
- run: flake8 run.py core
|
- run: flake8 run.py core
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ torch==2.0.1
|
|||||||
onnxruntime-gpu==1.15.0
|
onnxruntime-gpu==1.15.0
|
||||||
tensorflow==2.12.0
|
tensorflow==2.12.0
|
||||||
opennsfw2==0.10.2
|
opennsfw2==0.10.2
|
||||||
protobuf==3.20.3
|
protobuf==4.23.2
|
||||||
tqdm==4.65.0
|
tqdm==4.65.0
|
||||||
|
|||||||
15
run.py
15
run.py
@@ -3,7 +3,6 @@
|
|||||||
import platform
|
import platform
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
import shutil
|
import shutil
|
||||||
import glob
|
import glob
|
||||||
import argparse
|
import argparse
|
||||||
@@ -63,8 +62,8 @@ def limit_resources():
|
|||||||
|
|
||||||
|
|
||||||
def pre_check():
|
def pre_check():
|
||||||
if sys.version_info < (3, 8):
|
if sys.version_info < (3, 9):
|
||||||
quit('Python version is not supported - please upgrade to 3.8 or higher')
|
quit('Python version is not supported - please upgrade to 3.9 or higher')
|
||||||
if not shutil.which('ffmpeg'):
|
if not shutil.which('ffmpeg'):
|
||||||
quit('ffmpeg is not installed!')
|
quit('ffmpeg is not installed!')
|
||||||
model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'inswapper_128.onnx')
|
model_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'inswapper_128.onnx')
|
||||||
@@ -89,12 +88,8 @@ def pre_check():
|
|||||||
|
|
||||||
|
|
||||||
def start_processing():
|
def start_processing():
|
||||||
start_time = time.time()
|
|
||||||
if args['gpu']:
|
if args['gpu']:
|
||||||
process_video(args['source_img'], args["frame_paths"])
|
process_video(args['source_img'], args["frame_paths"])
|
||||||
end_time = time.time()
|
|
||||||
print(flush=True)
|
|
||||||
print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True)
|
|
||||||
return
|
return
|
||||||
frame_paths = args["frame_paths"]
|
frame_paths = args["frame_paths"]
|
||||||
n = len(frame_paths)//(args['cores_count'])
|
n = len(frame_paths)//(args['cores_count'])
|
||||||
@@ -106,9 +101,6 @@ def start_processing():
|
|||||||
p.get()
|
p.get()
|
||||||
pool.close()
|
pool.close()
|
||||||
pool.join()
|
pool.join()
|
||||||
end_time = time.time()
|
|
||||||
print(flush=True)
|
|
||||||
print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True)
|
|
||||||
|
|
||||||
|
|
||||||
def preview_image(image_path):
|
def preview_image(image_path):
|
||||||
@@ -176,7 +168,6 @@ def status(string):
|
|||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
print("DON'T WORRY. IT'S NOT STUCK/CRASHED.\n" * 5)
|
|
||||||
if not args['source_img'] or not os.path.isfile(args['source_img']):
|
if not args['source_img'] or not os.path.isfile(args['source_img']):
|
||||||
print("\n[WARNING] Please select an image containing a face.")
|
print("\n[WARNING] Please select an image containing a face.")
|
||||||
return
|
return
|
||||||
@@ -199,7 +190,7 @@ def start():
|
|||||||
process_img(args['source_img'], target_path, args['output_file'])
|
process_img(args['source_img'], target_path, args['output_file'])
|
||||||
status("swap successful!")
|
status("swap successful!")
|
||||||
return
|
return
|
||||||
seconds, probabilities = predict_video_frames(video_path=args['target_path'], frame_interval=50)
|
seconds, probabilities = predict_video_frames(video_path=args['target_path'], frame_interval=100)
|
||||||
if any(probability > 0.7 for probability in probabilities):
|
if any(probability > 0.7 for probability in probabilities):
|
||||||
quit()
|
quit()
|
||||||
video_name_full = target_path.split("/")[-1]
|
video_name_full = target_path.split("/")[-1]
|
||||||
|
|||||||
Reference in New Issue
Block a user