2022-10-01 18:35:42 +08:00
|
|
|
# Copyright (c) Alibaba, Inc. and its affiliates.
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
from modelscope.pipelines import pipeline
|
|
|
|
|
from modelscope.pipelines.base import Pipeline
|
|
|
|
|
from modelscope.utils.constant import Tasks
|
|
|
|
|
from modelscope.utils.test_utils import test_level
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FaceEmotionTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
def setUp(self) -> None:
|
|
|
|
|
self.model = 'damo/cv_face-emotion'
|
2023-09-05 10:42:43 +08:00
|
|
|
self.img = 'data/test/images/face_emotion.jpg'
|
2022-10-01 18:35:42 +08:00
|
|
|
|
|
|
|
|
def pipeline_inference(self, pipeline: Pipeline, input: str):
|
|
|
|
|
result = pipeline(input)
|
|
|
|
|
print(result)
|
|
|
|
|
|
2022-10-30 11:15:52 +08:00
|
|
|
@unittest.skip('skip since the model is set to private for now')
|
2022-10-01 18:35:42 +08:00
|
|
|
def test_run_modelhub(self):
|
|
|
|
|
face_emotion = pipeline(Tasks.face_emotion, model=self.model)
|
|
|
|
|
self.pipeline_inference(face_emotion, self.img)
|
|
|
|
|
|
2022-10-30 11:15:52 +08:00
|
|
|
@unittest.skip('skip since the model is set to private for now')
|
2022-10-01 18:35:42 +08:00
|
|
|
def test_run_modelhub_default_model(self):
|
|
|
|
|
face_emotion = pipeline(Tasks.face_emotion)
|
|
|
|
|
self.pipeline_inference(face_emotion, self.img)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|