fix install wip

main
Tran Xen 2 years ago
parent 054f693815
commit f9fc0bbff1

@ -3,6 +3,8 @@ dill
ifnude
insightface==0.7.3
onnx>=1.14.0
protobuf>=3.20.2
opencv-python
pandas
pydantic
safetensors

@ -1,3 +1,4 @@
protobuf>=3.20.2
cython
dill
ifnude

@ -29,12 +29,15 @@ def check_against_nsfw(img: PILImage) -> bool:
chunks: List[Dict[str, Union[int, float]]] = detect(img)
for chunk in chunks:
logger.debug(
f"chunck score {chunk['score']}, threshold : {NSFW_SCORE_THRESHOLD}"
)
shapes.append(chunk["score"] > NSFW_SCORE_THRESHOLD)
return any(shapes)
def pil_to_cv2(pil_img: PILImage) -> CV2ImgU8: # type: ignore
def pil_to_cv2(pil_img: PILImage) -> CV2ImgU8:
"""
Convert a PIL Image into an OpenCV image (cv2).
@ -44,7 +47,7 @@ def pil_to_cv2(pil_img: PILImage) -> CV2ImgU8: # type: ignore
Returns:
CV2ImgU8: The input image converted to OpenCV format (BGR).
"""
return cv2.cvtColor(np.array(pil_img), cv2.COLOR_RGB2BGR)
return cv2.cvtColor(np.array(pil_img), cv2.COLOR_RGB2BGR).astype("uint8")
def cv2_to_pil(cv2_img: CV2ImgU8) -> PILImage: # type: ignore

@ -1,10 +1,10 @@
from typing import Tuple
from numpy import uint8
from numpy.typing import NDArray
from insightface.app.common import Face as IFace
from PIL import Image
import numpy as np
PILImage = Image.Image
CV2ImgU8 = NDArray[uint8]
CV2ImgU8 = np.ndarray[int, np.dtype[uint8]]
Face = IFace
BoxCoords = Tuple[int, int, int, int]

Loading…
Cancel
Save