From ca1c720cd942046cd6276db809a7f20da42e6f75 Mon Sep 17 00:00:00 2001 From: "qianming.lm" Date: Tue, 2 Aug 2022 22:23:13 +0800 Subject: [PATCH] [to #42322933] add cv_resnet50_live-category to maas lib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于全规需要,修改了透出标签,将后台类目映射为前台类目,并修改了代码,不再透出层级类目,只透出最终细分类目。 Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9615279 --- modelscope/outputs.py | 11 +++++++++-- modelscope/pipelines/cv/live_category_pipeline.py | 2 +- modelscope/utils/constant.py | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modelscope/outputs.py b/modelscope/outputs.py index 30860f29..0937e441 100644 --- a/modelscope/outputs.py +++ b/modelscope/outputs.py @@ -159,10 +159,17 @@ TASK_OUTPUTS = { # } Tasks.action_recognition: [OutputKeys.LABELS], + # live category recognition result for single video + # { + # "scores": [0.885272, 0.014790631, 0.014558001], + # 'labels': ['修身型棉衣', '高腰牛仔裤', '休闲连体裤'] + # } + Tasks.live_category: [OutputKeys.SCORES, OutputKeys.LABELS], + # video category recognition result for single video # { - # "scores": [0.7716429233551025] - # "labels": ['生活>>好物推荐'], + # "scores": [0.7716429233551025], + # "labels": ['生活>>好物推荐'] # } Tasks.video_category: [OutputKeys.SCORES, OutputKeys.LABELS], diff --git a/modelscope/pipelines/cv/live_category_pipeline.py b/modelscope/pipelines/cv/live_category_pipeline.py index b7f3202e..c16ba6ba 100644 --- a/modelscope/pipelines/cv/live_category_pipeline.py +++ b/modelscope/pipelines/cv/live_category_pipeline.py @@ -85,7 +85,7 @@ class LiveCategoryPipeline(Pipeline): for label_key in label_keys: if label_info[label_key] not in label_str: label_str.append(label_info[label_key]) - labels.append('>>'.join(label_str)) + labels.append(label_str[-1]) return {OutputKeys.SCORES: list(scores), OutputKeys.LABELS: labels} def postprocess(self, inputs: Dict[str, Any]) -> Dict[str, Any]: diff --git a/modelscope/utils/constant.py b/modelscope/utils/constant.py index ef3c4f4f..4d4ad9e9 100644 --- a/modelscope/utils/constant.py +++ b/modelscope/utils/constant.py @@ -61,7 +61,6 @@ class CVTasks(object): video_category = 'video-category' video_embedding = 'video-embedding' - virtual_try_on = 'virtual-try-on'