UPDATE: Analyzer logic
+VersionUP (0.5.0 alpha3)
This commit is contained in:
parent
bbc2481494
commit
524c4b78b3
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_red.png?raw=true" alt="logo" width="180px"/>
|
<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_red.png?raw=true" alt="logo" width="180px"/>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<a href='https://ko-fi.com/gourieff' target='_blank'><img height='33' src='https://storage.ko-fi.com/cdn/kofi3.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
<a href='https://ko-fi.com/gourieff' target='_blank'><img height='33' src='https://storage.ko-fi.com/cdn/kofi3.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_red.png?raw=true" alt="logo" width="180px"/>
|
<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_red.png?raw=true" alt="logo" width="180px"/>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<a href='https://ko-fi.com/gourieff' target='_blank'><img height='33' src='https://storage.ko-fi.com/cdn/kofi3.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
<a href='https://ko-fi.com/gourieff' target='_blank'><img height='33' src='https://storage.ko-fi.com/cdn/kofi3.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import List, Union, Tuple
|
from typing import List, Union
|
||||||
from functools import lru_cache
|
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -95,17 +94,7 @@ def getAnalysisModel():
|
|||||||
)
|
)
|
||||||
return ANALYSIS_MODEL
|
return ANALYSIS_MODEL
|
||||||
|
|
||||||
@lru_cache(maxsize=3)
|
|
||||||
def getAnalysisModel_CUDA(det_size: Tuple[int, int] = (640, 640)):
|
|
||||||
global ANALYSIS_MODEL
|
|
||||||
if ANALYSIS_MODEL is None:
|
|
||||||
ANALYSIS_MODEL = insightface.app.FaceAnalysis(
|
|
||||||
name="buffalo_l", providers=PROVIDERS, root=os.path.join(models_path, "insightface") # note: allowed_modules=['detection', 'genderage']
|
|
||||||
)
|
|
||||||
ANALYSIS_MODEL.prepare(ctx_id=0, det_size=det_size)
|
|
||||||
return ANALYSIS_MODEL
|
|
||||||
|
|
||||||
@lru_cache(maxsize=1)
|
|
||||||
def getFaceSwapModel(model_path: str):
|
def getFaceSwapModel(model_path: str):
|
||||||
global FS_MODEL
|
global FS_MODEL
|
||||||
global CURRENT_FS_MODEL_PATH
|
global CURRENT_FS_MODEL_PATH
|
||||||
@ -233,11 +222,8 @@ def half_det_size(det_size):
|
|||||||
|
|
||||||
def analyze_faces(img_data: np.ndarray, det_size=(640, 640)):
|
def analyze_faces(img_data: np.ndarray, det_size=(640, 640)):
|
||||||
logger.info("Applied Execution Provider: %s", PROVIDERS[0])
|
logger.info("Applied Execution Provider: %s", PROVIDERS[0])
|
||||||
if DEVICE == "CUDA":
|
face_analyser = copy.deepcopy(getAnalysisModel())
|
||||||
face_analyser = getAnalysisModel_CUDA(det_size)
|
face_analyser.prepare(ctx_id=0, det_size=det_size)
|
||||||
else:
|
|
||||||
face_analyser = copy.deepcopy(getAnalysisModel())
|
|
||||||
face_analyser.prepare(ctx_id=0, det_size=det_size)
|
|
||||||
return face_analyser.get(img_data)
|
return face_analyser.get(img_data)
|
||||||
|
|
||||||
def get_face_single(img_data: np.ndarray, face, face_index=0, det_size=(640, 640), gender_source=0, gender_target=0):
|
def get_face_single(img_data: np.ndarray, face, face_index=0, det_size=(640, 640), gender_source=0, gender_target=0):
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
app_title = "ReActor"
|
app_title = "ReActor"
|
||||||
version_flag = "v0.5.0-a2"
|
version_flag = "v0.5.0-a3"
|
||||||
|
|
||||||
from scripts.reactor_logger import logger, get_Run, set_Run
|
from scripts.reactor_logger import logger, get_Run, set_Run
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user