Gmgge / ImageAnalysisService

轻量模型的图像分析web服务,包括倾斜矫正OCR,公章(印章)检测+识别,车牌识别。api方案使用FastAPI+Gunicorn,提供gradio展示。
61 stars 10 forks source link

picodet.py里classes的作用是什么? #9

Closed Einsmai closed 4 months ago

Einsmai commented 5 months ago

作者,您好,我在研读你的项目时,遇到一个问题卡住想不通:

class PicoDet(object): def init(self, module_args=seal_detect_args):

读取模型信息

    self.classes = list(map(lambda x: x.strip(), open(module_args.label_path, 'r').readlines()))
    self.score_thresh = module_args.score_thresh
    self.nms_thresh = module_args.nms_thresh
    self.mean = np.array([0.406, 0.456, 0.485], dtype=np.float32).reshape(1, 1, 3)
    self.std = np.array([0.225, 0.224, 0.229], dtype=np.float32).reshape(1, 1, 3)
    # 设置推理配置
    options = ort.SessionOptions()
    options.log_severity_level = 3
    # 构建推理会话
    self.net = ort.InferenceSession(module_args.model_path, options)
    inputs_name = [a.name for a in self.net.get_inputs()]
    inputs_shape = {k: v.shape for k, v in zip(inputs_name, self.net.get_inputs())}
    self.input_shape = inputs_shape['image'][2:]
    # 绘制参数
    self.color_list = get_color_map_list(len(self.classes))

classes 变量是读取的一份文件,请问可以透露里面是什么内容吗? 我的推测似乎是一些颜色配置参数,是这样的吗?

Gmgge commented 5 months ago

self.classes 是类别列表,例如你检测两个目标seal、people,那么这个classes[seal, people]。get_color_map_list是一个生成多个颜色map的函数,这样在绘制的时候,使用不同颜色绘制不同的目标。