Revert model and Fixes

pull/286/head
Jason Kneen 2024-08-14 00:53:52 +01:00
parent 6cda41de6c
commit b20d797581
5 changed files with 23 additions and 7 deletions

View File

@ -87,7 +87,7 @@ pip install onnxruntime-silicon==1.13.1
2. Usage in case the provider is available:
```
python run.py --execution-provider metal
python run.py --execution-provider coreml
```

View File

@ -75,13 +75,13 @@ def parse_args() -> None:
program.add_argument('--keep-audio', help='keep original audio', dest='keep_audio', action='store_true', default=True)
program.add_argument('--keep-frames', help='keep temporary frames', dest='keep_frames', action='store_true', default=True)
program.add_argument('--many-faces', help='process every face', dest='many_faces', action='store_true', default=False)
program.add_argument('--video-encoder', help='adjust output video encoder', dest='video_encoder', default='libx265', choices=['libx264', 'libx265', 'libvpx-vp9'])
program.add_argument('--video-encoder', help='adjust output video encoder', dest='video_encoder', default='libvpx-vp9', choices=['libx264', 'libx265', 'libvpx-vp9'])
program.add_argument('--video-quality', help='adjust output video quality', dest='video_quality', type=int, default=1, choices=range(52), metavar='[0-51]')
program.add_argument('--max-memory', help='maximum amount of RAM in GB', dest='max_memory', type=int, default=suggest_max_memory())
program.add_argument('--execution-provider', help='execution provider', dest='execution_provider', default=['coreml'], choices=suggest_execution_providers(), nargs='+')
program.add_argument('--execution-threads', help='number of execution threads', dest='execution_threads', type=int, default=suggest_execution_threads())
program.add_argument('--video-processor', help='video processor to use', dest='video_processor', default='cv2', choices=['cv2', 'ffmpeg'])
program.add_argument('--model', help='model to use for face swapping', dest='model', default='inswapper_128v2.fp16.onnx')
program.add_argument('--model', help='model to use for face swapping', dest='model', default='inswapper_128.onnx')
program.add_argument('-v', '--version', action='version', version=f'{modules.metadata.name} {modules.metadata.version}')
args = program.parse_args()

View File

@ -24,6 +24,7 @@ execution_providers: List[str] = []
execution_threads = None
headless = None
log_level = 'error'
model = None
fp_ui: Dict[str, bool] = {}
nsfw = None
camera_input_combobox = None

View File

@ -18,7 +18,7 @@ NAME = 'DLC.FACE-SWAPPER'
def pre_check() -> bool:
download_directory_path = resolve_relative_path('../models')
conditional_download(download_directory_path, ['https://huggingface.co/hacksider/deep-live-cam/blob/main/inswapper_128.onnx'])
conditional_download(download_directory_path, ['https://huggingface.co/hacksider/deep-live-cam/blob/main/' + modules.globals.model])
return True
@ -40,7 +40,7 @@ def get_face_swapper() -> Any:
with THREAD_LOCK:
if FACE_SWAPPER is None:
model_path = resolve_relative_path('../models/inswapper_128.onnx')
model_path = resolve_relative_path('../models/' + modules.globals.model)
FACE_SWAPPER = insightface.model_zoo.get_model(model_path, providers=modules.globals.execution_providers)
return FACE_SWAPPER

View File

@ -27,8 +27,8 @@ def run_ffmpeg(args: List[str]) -> bool:
try:
subprocess.check_output(commands, stderr=subprocess.STDOUT)
return True
except Exception:
pass
except subprocess.CalledProcessError as e:
print(f"FFmpeg error: {e.output.decode().strip()}") # Capture and print the error message
return False
@ -60,6 +60,21 @@ def extract_frames(target_path: str) -> None:
cap.release()
def extract_frames_ffmpeg(target_path: str) -> None:
temp_directory_path = get_temp_directory_path(target_path)
os.makedirs(temp_directory_path, exist_ok=True) # Ensure output directory exists
try:
(
ffmpeg
.input(target_path)
.output(os.path.join(temp_directory_path, '%04d.png'), start_number=0)
.overwrite_output()
.run(capture_stdout=True, capture_stderr=True)
)
except Exception as e:
print(f"Error running FFmpeg: {str(e)}")
def create_video(target_path: str, fps: float = 30.0) -> None:
temp_output_path = get_temp_output_path(target_path)
temp_directory_path = get_temp_directory_path(target_path)