Browse Source

add five finetune task & merge master

master
翎航 2 years ago
parent
commit
a02b2409d8
2 changed files with 10 additions and 4 deletions
  1. +0
    -1
      modelscope/preprocessors/ofa/summarization.py
  2. +10
    -3
      tests/trainers/test_ofa_trainer.py

+ 0
- 1
modelscope/preprocessors/ofa/summarization.py View File

@@ -46,7 +46,6 @@ class OfaSummarizationPreprocessor(OfaBasePreprocessor):
def _build_infer_sample(self, data: Dict[str, Any]) -> Dict[str, Any]:
source = super().pre_caption(
data[self.column_map['text']], max_words=self.max_src_length)
# source = source.strip()[:self.max_src_length]
source = source.replace('[unk]', 'unk').replace('<unk>', 'unk')
prompt = self.cfg.model.get(
'prompt', ' " {} " Summarize the article with a title: ')


+ 10
- 3
tests/trainers/test_ofa_trainer.py View File

@@ -71,13 +71,20 @@ class TestOfaTrainer(unittest.TestCase):

@unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
def test_trainer_std(self):
# WORKSPACE = './workspace/ckpts/recognition'
# os.makedirs(WORKSPACE, exist_ok=True)
#
# pretrained_model = 'damo/ofa_ocr-recognition_scene_base_zh'
# cfg = read_config(pretrained_model)
# config_file = os.path.join(WORKSPACE, ModelFile.CONFIGURATION)
# cfg.dump(config_file)
WORKSPACE = './workspace/ckpts/recognition'
os.makedirs(WORKSPACE, exist_ok=True)
config_file = os.path.join(WORKSPACE, ModelFile.CONFIGURATION)
with open(config_file, 'w') as writer:
json.dump(self.finetune_cfg, writer)

pretrained_model = 'damo/ofa_ocr-recognition_scene_base_zh'
cfg = read_config(pretrained_model)
config_file = os.path.join(WORKSPACE, ModelFile.CONFIGURATION)
cfg.dump(config_file)

args = dict(
model=pretrained_model,


Loading…
Cancel
Save