* Update official url for cuda 12-2 wheels

* Fix preview for audio to image

* Prevent download loop when remote is unreachable

* Prevent download loop when remote is unreachable

* changes (#444)

* Tidy up monkey patch

* Use cpu core count for concurrency count

* Dynamic concurrency_count for ideal Gradio performance

* Conditional download face analyser models

* Fix testing via pre_check()

* Introduce checking to process manager for blocking the UI

* Introduce checking to process manager for blocking the UI

* Introduce checking to process manager for blocking the UI

* Introduce checking to process manager for blocking the UI

* Move the blocking while model download to the correct position

* Remove unused imports

---------

Co-authored-by: Harisreedhar <46858047+harisreedhar@users.noreply.github.com>
This commit is contained in:
Henry Ruhs
2024-03-20 10:02:08 +01:00
committed by GitHub
parent 1e2031e149
commit 6e67d7bff6
21 changed files with 133 additions and 52 deletions

View File

@@ -1,10 +1,12 @@
from typing import Any, Optional, List, Tuple
from time import sleep
import threading
import cv2
import numpy
import onnxruntime
import facefusion.globals
from facefusion import process_manager
from facefusion.common_helper import get_first
from facefusion.face_helper import warp_face_by_face_landmark_5, warp_face_by_translation, create_static_anchors, distance_to_face_landmark_5, distance_to_bounding_box, convert_face_landmark_68_to_5, apply_nms, categorize_age, categorize_gender
from facefusion.face_store import get_static_faces, set_static_faces
@@ -77,6 +79,8 @@ def get_face_analyser() -> Any:
face_detectors = {}
with THREAD_LOCK:
while process_manager.is_checking():
sleep(0.5)
if FACE_ANALYSER is None:
if facefusion.globals.face_detector_model in [ 'many', 'retinaface' ]:
face_detector = onnxruntime.InferenceSession(MODELS.get('face_detector_retinaface').get('path'), providers = apply_execution_provider_options(facefusion.globals.execution_providers))
@@ -121,18 +125,29 @@ def pre_check() -> bool:
download_directory_path = resolve_relative_path('../.assets/models')
model_urls =\
[
MODELS.get('face_detector_retinaface').get('url'),
MODELS.get('face_detector_scrfd').get('url'),
MODELS.get('face_detector_yoloface').get('url'),
MODELS.get('face_detector_yunet').get('url'),
MODELS.get('face_recognizer_arcface_blendswap').get('url'),
MODELS.get('face_recognizer_arcface_inswapper').get('url'),
MODELS.get('face_recognizer_arcface_simswap').get('url'),
MODELS.get('face_recognizer_arcface_uniface').get('url'),
MODELS.get('face_landmarker').get('url'),
MODELS.get('gender_age').get('url'),
MODELS.get('gender_age').get('url')
]
if facefusion.globals.face_detector_model in [ 'many', 'retinaface' ]:
model_urls.append(MODELS.get('face_detector_retinaface').get('url'))
if facefusion.globals.face_detector_model in [ 'many', 'scrfd' ]:
model_urls.append(MODELS.get('face_detector_scrfd').get('url'))
if facefusion.globals.face_detector_model in [ 'many', 'yoloface' ]:
model_urls.append(MODELS.get('face_detector_yoloface').get('url'))
if facefusion.globals.face_detector_model in [ 'yunet' ]:
model_urls.append(MODELS.get('face_detector_yunet').get('url'))
if facefusion.globals.face_recognizer_model == 'arcface_blendswap':
model_urls.append(MODELS.get('face_recognizer_arcface_blendswap').get('url'))
if facefusion.globals.face_recognizer_model == 'arcface_inswapper':
model_urls.append(MODELS.get('face_recognizer_arcface_inswapper').get('url'))
if facefusion.globals.face_recognizer_model == 'arcface_simswap':
model_urls.append(MODELS.get('face_recognizer_arcface_simswap').get('url'))
if facefusion.globals.face_recognizer_model == 'arcface_uniface':
model_urls.append(MODELS.get('face_recognizer_arcface_uniface').get('url'))
process_manager.check()
conditional_download(download_directory_path, model_urls)
process_manager.end()
return True