mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-08-21 14:03:20 -07:00
splitting large files
This commit is contained in:
parent
30cc36c8e4
commit
ee7d471f20
16 changed files with 805308 additions and 7 deletions
41
modelhub/cv/FaceMarkerLBF/FaceMarkerLBF.py
Normal file
41
modelhub/cv/FaceMarkerLBF/FaceMarkerLBF.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
from pathlib import Path
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
from xlib.image import ImageProcessor
|
||||
from xlib.file import SplittedFile
|
||||
|
||||
class FaceMarkerLBF:
|
||||
def __init__(self):
|
||||
path = Path(__file__).parent / 'lbfmodel.yaml'
|
||||
SplittedFile.merge(path, delete_parts=False)
|
||||
|
||||
marker = self.marker = cv2.face.createFacemarkLBF()
|
||||
marker.loadModel(str(path))
|
||||
|
||||
def extract(self, img : np.ndarray):
|
||||
"""
|
||||
arguments
|
||||
|
||||
img np.ndarray HW,HWC,NHWC
|
||||
|
||||
returns
|
||||
|
||||
[N,68,2]
|
||||
"""
|
||||
ip = ImageProcessor(img)
|
||||
|
||||
N,H,W,_ = ip.get_dims()
|
||||
|
||||
feed_img = ip.to_grayscale().to_uint8().get_image('NHWC')
|
||||
|
||||
lmrks_list = []
|
||||
for n in range( max(1,N) ):
|
||||
_, lmrks = self.marker.fit(feed_img[n], np.array([ [0,0,W,H] ]) )
|
||||
lmrks = lmrks[0][0]
|
||||
|
||||
lmrks_list.append(lmrks)
|
||||
|
||||
return np.float32(lmrks_list)
|
||||
|
||||
|
511064
modelhub/cv/FaceMarkerLBF/lbfmodel.yaml.part0
Normal file
511064
modelhub/cv/FaceMarkerLBF/lbfmodel.yaml.part0
Normal file
File diff suppressed because it is too large
Load diff
294122
modelhub/cv/FaceMarkerLBF/lbfmodel.yaml.part1
Normal file
294122
modelhub/cv/FaceMarkerLBF/lbfmodel.yaml.part1
Normal file
File diff suppressed because it is too large
Load diff
1
modelhub/cv/__init__.py
Normal file
1
modelhub/cv/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from .FaceMarkerLBF.FaceMarkerLBF import FaceMarkerLBF
|
BIN
modelhub/onnx/S3FD/S3FD.onnx.part0
Normal file
BIN
modelhub/onnx/S3FD/S3FD.onnx.part0
Normal file
Binary file not shown.
BIN
modelhub/onnx/S3FD/S3FD.onnx.part1
Normal file
BIN
modelhub/onnx/S3FD/S3FD.onnx.part1
Normal file
Binary file not shown.
|
@ -7,6 +7,7 @@ from xlib.image import ImageProcessor
|
|||
from xlib.onnxruntime import (InferenceSession_with_device, ORTDeviceInfo,
|
||||
get_available_devices_info)
|
||||
|
||||
from xlib.file import SplittedFile
|
||||
|
||||
class S3FD:
|
||||
|
||||
|
@ -19,6 +20,8 @@ class S3FD:
|
|||
raise Exception(f'device_info {device_info} is not in available devices for S3FD')
|
||||
|
||||
path = Path(__file__).parent / 'S3FD.onnx'
|
||||
SplittedFile.merge(path, delete_parts=False)
|
||||
|
||||
self._sess = sess = InferenceSession_with_device(str(path), device_info)
|
||||
self._input_name = sess.get_inputs()[0].name
|
||||
|
||||
|
|
BIN
modelhub/torch/S3FD/S3FD.pth.part0
Normal file
BIN
modelhub/torch/S3FD/S3FD.pth.part0
Normal file
Binary file not shown.
BIN
modelhub/torch/S3FD/S3FD.pth.part1
Normal file
BIN
modelhub/torch/S3FD/S3FD.pth.part1
Normal file
Binary file not shown.
|
@ -6,6 +6,7 @@ import torch
|
|||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
from xlib import math as lib_math
|
||||
from xlib.file import SplittedFile
|
||||
from xlib.image import ImageProcessor
|
||||
from xlib.torch import TorchDeviceInfo, get_cpu_device
|
||||
|
||||
|
@ -15,9 +16,12 @@ class S3FD:
|
|||
if device_info is None:
|
||||
device_info = get_cpu_device()
|
||||
self.device_info = device_info
|
||||
|
||||
|
||||
path = Path(__file__).parent / 'S3FD.pth'
|
||||
SplittedFile.merge(path, delete_parts=False)
|
||||
|
||||
net = self.net = S3FDNet()
|
||||
net.load_state_dict( torch.load(str(Path(__file__).parent / 's3fd.pth')) )
|
||||
net.load_state_dict( torch.load(str(path) ))
|
||||
net.eval()
|
||||
|
||||
if not device_info.is_cpu():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue