UPDATE: Analyzer logic

+VersionUP (0.5.0 alpha3)
This commit is contained in:
Gourieff 2023-11-04 23:57:15 +07:00
parent bbc2481494
commit 524c4b78b3
4 changed files with 6 additions and 20 deletions

View File

@ -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"/>
![Version](https://img.shields.io/badge/version-0.5.0_alpha2-lightgreen?style=for-the-badge&labelColor=darkgreen)
![Version](https://img.shields.io/badge/version-0.5.0_alpha3-lightgreen?style=for-the-badge&labelColor=darkgreen)
<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>

View File

@ -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"/>
![Version](https://img.shields.io/badge/версия-0.5.0_alpha2-lightgreen?style=for-the-badge&labelColor=darkgreen)
![Version](https://img.shields.io/badge/версия-0.5.0_alpha3-lightgreen?style=for-the-badge&labelColor=darkgreen)
<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>

View File

@ -1,8 +1,7 @@
import copy
import os
from dataclasses import dataclass
from typing import List, Union, Tuple
from functools import lru_cache
from typing import List, Union
import cv2
import numpy as np
@ -95,17 +94,7 @@ def getAnalysisModel():
)
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):
global FS_MODEL
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)):
logger.info("Applied Execution Provider: %s", PROVIDERS[0])
if DEVICE == "CUDA":
face_analyser = getAnalysisModel_CUDA(det_size)
else:
face_analyser = copy.deepcopy(getAnalysisModel())
face_analyser.prepare(ctx_id=0, det_size=det_size)
face_analyser = copy.deepcopy(getAnalysisModel())
face_analyser.prepare(ctx_id=0, det_size=det_size)
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):

View File

@ -1,5 +1,5 @@
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