mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-24 12:09:22 +01:00
[to #42322933] move input face_deteciton pipeline into face_recognition init
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9652773 * move input face_deteciton pipeline into face_recognition init
This commit is contained in:
@@ -24,12 +24,11 @@ logger = get_logger()
|
||||
Tasks.face_recognition, module_name=Pipelines.face_recognition)
|
||||
class FaceRecognitionPipeline(Pipeline):
|
||||
|
||||
def __init__(self, model: str, face_detection: Pipeline, **kwargs):
|
||||
def __init__(self, model: str, **kwargs):
|
||||
"""
|
||||
use `model` to create a face recognition pipeline for prediction
|
||||
Args:
|
||||
model: model id on modelscope hub.
|
||||
face_detecion: pipeline for face detection and face alignment before recognition
|
||||
"""
|
||||
|
||||
# face recong model
|
||||
@@ -47,7 +46,9 @@ class FaceRecognitionPipeline(Pipeline):
|
||||
self.face_model = face_model
|
||||
logger.info('face recognition model loaded!')
|
||||
# face detect pipeline
|
||||
self.face_detection = face_detection
|
||||
det_model_id = 'damo/cv_resnet_facedetection_scrfd10gkps'
|
||||
self.face_detection = pipeline(
|
||||
Tasks.face_detection, model=det_model_id)
|
||||
|
||||
def _choose_face(self,
|
||||
det_result,
|
||||
|
||||
@@ -17,20 +17,15 @@ from modelscope.utils.test_utils import test_level
|
||||
class FaceRecognitionTest(unittest.TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.recog_model_id = 'damo/cv_ir101_facerecognition_cfglint'
|
||||
self.det_model_id = 'damo/cv_resnet_facedetection_scrfd10gkps'
|
||||
self.model_id = 'damo/cv_ir101_facerecognition_cfglint'
|
||||
|
||||
@unittest.skipUnless(test_level() >= 1, 'skip test in current test level')
|
||||
def test_face_compare(self):
|
||||
img1 = 'data/test/images/face_recognition_1.png'
|
||||
img2 = 'data/test/images/face_recognition_2.png'
|
||||
|
||||
face_detection = pipeline(
|
||||
Tasks.face_detection, model=self.det_model_id)
|
||||
face_recognition = pipeline(
|
||||
Tasks.face_recognition,
|
||||
face_detection=face_detection,
|
||||
model=self.recog_model_id)
|
||||
Tasks.face_recognition, model=self.model_id)
|
||||
# note that for dataset output, the inference-output is a Generator that can be iterated.
|
||||
emb1 = face_recognition(img1)[OutputKeys.IMG_EMBEDDING]
|
||||
emb2 = face_recognition(img2)[OutputKeys.IMG_EMBEDDING]
|
||||
|
||||
Reference in New Issue
Block a user