EasyCV icon indicating copy to clipboard operation
EasyCV copied to clipboard

feature: export head for moby

Open yang-ruixin opened this issue 1 year ago • 1 comments

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Please describe the motivation of this PR and the goal you want to achieve through this PR. 在导出模型并推理得到特征时,MoBY算法只能导出backbone特征,或者neck (ie, projector_q) 特征,无法导出head (ie, predictor) 特征。 head特征可直接用于以图搜图等项目,这个PR实现导出模型及推理得到head特征的功能。 之前已提issue 260,请见下面链接 https://github.com/alibaba/EasyCV/issues/260

Modification

Please briefly describe what modification is made in this PR.

  1. .\easycv\apis\export.py,修改def _export_moby(model, cfg, filename)
  2. .\easycv\models\classification\classification.py,修改def forward_feature(self, img)
  3. .\easycv\models\heads\moby_head.py,新增这个文件
  4. .\easycv\models\heads_init_.py
  5. .\configs\selfsup\moby*,添加export_head功能export = dict(export_neck=True, export_head=True)

Backward-Compatibility-Breaking (Optional)

Does the modification introduce changes that break the backward-compatibility? If so, please describe how it breaks the compatibility in this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation. 如链接最下面提取特征例子所示https://github.com/alibaba/EasyCV/blob/master/docs/source/tutorials/ssl.md 如果在config文件.\configs\selfsup\moby*,设置export = dict(export_neck=True, export_head=True),当设置export_head=True时,无论export_neck设置为True或False,都会得到head (ie, predictor)特征

Pull-Request Todo List

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. The documentation has been modified accordingly, like docstring or example tutorials.

yang-ruixin avatar Jan 08 '23 17:01 yang-ruixin