Skip to content

Commit

Permalink
fix install wip
Browse files Browse the repository at this point in the history
  • Loading branch information
glucauze committed Aug 15, 2023
1 parent 054f693 commit f9fc0bb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions requirements-gpu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ dill
ifnude
insightface==0.7.3
onnx>=1.14.0
protobuf>=3.20.2
opencv-python
pandas
pydantic
safetensors
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
protobuf>=3.20.2
cython
dill
ifnude
Expand Down
7 changes: 5 additions & 2 deletions scripts/faceswaplab_utils/imgutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/faceswaplab_utils/typing.py
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit f9fc0bb

Please sign in to comment.