Browse Source

[to #42322933]修复nano模型初始化/增加文件copyright信息

修复nano模型初始化/增加文件copyright信息
        Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10247456
master
leyuan.hjy yingda.chen 3 years ago
parent
commit
f844f73b03
3 changed files with 9 additions and 2 deletions
  1. +6
    -1
      modelscope/models/cv/realtime_object_detection/realtime_detector.py
  2. +2
    -1
      modelscope/models/cv/realtime_object_detection/yolox/exp/default/yolox_nano.py
  3. +1
    -0
      modelscope/pipelines/cv/realtime_object_detection_pipeline.py

+ 6
- 1
modelscope/models/cv/realtime_object_detection/realtime_detector.py View File

@@ -1,3 +1,4 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
import argparse import argparse
import logging as logger import logging as logger
import os import os
@@ -48,6 +49,7 @@ class RealtimeDetector(TorchModel):
self.nmsthre = self.exp.nmsthre self.nmsthre = self.exp.nmsthre
self.test_size = self.exp.test_size self.test_size = self.exp.test_size
self.preproc = ValTransform(legacy=False) self.preproc = ValTransform(legacy=False)
self.label_mapping = self.config['labels']


def inference(self, img): def inference(self, img):
with torch.no_grad(): with torch.no_grad():
@@ -81,5 +83,8 @@ class RealtimeDetector(TorchModel):
bboxes = outputs[0][:, 0:4].cpu().numpy() / self.ratio bboxes = outputs[0][:, 0:4].cpu().numpy() / self.ratio
scores = outputs[0][:, 5].cpu().numpy() scores = outputs[0][:, 5].cpu().numpy()
labels = outputs[0][:, 6].cpu().int().numpy() labels = outputs[0][:, 6].cpu().int().numpy()
pred_label_names = []
for lab in labels:
pred_label_names.append(self.label_mapping[lab])


return bboxes, scores, labels
return bboxes, scores, pred_label_names

+ 2
- 1
modelscope/models/cv/realtime_object_detection/yolox/exp/default/yolox_nano.py View File

@@ -42,5 +42,6 @@ class YoloXNanoExp(YoloXExp):
act=self.act, act=self.act,
depthwise=True) depthwise=True)
self.model = YOLOX(backbone, head) self.model = YOLOX(backbone, head)

self.model.apply(init_yolo)
self.model.head.initialize_biases(1e-2)
return self.model return self.model

+ 1
- 0
modelscope/pipelines/cv/realtime_object_detection_pipeline.py View File

@@ -1,3 +1,4 @@
# Copyright (c) Alibaba, Inc. and its affiliates.
import os.path as osp import os.path as osp
from typing import Any, Dict, List, Union from typing import Any, Dict, List, Union




Loading…
Cancel
Save