| @@ -92,9 +92,12 @@ def file_integrity_validation(file_path, expected_sha256): | |||||
| def create_library_statistics(method: str, | def create_library_statistics(method: str, | ||||
| name: str, | name: str, | ||||
| cn_name: Optional[str]): | cn_name: Optional[str]): | ||||
| path = f'{get_endpoint()}/api/v1/statistics/library' | |||||
| headers = {'user-agent': ModelScopeConfig.get_user_agent()} | |||||
| params = {"Method": method, "Name": name, "CnName": cn_name} | |||||
| r = requests.post(path, params=params, headers=headers) | |||||
| r.raise_for_status() | |||||
| try: | |||||
| path = f'{get_endpoint()}/api/v1/statistics/library' | |||||
| headers = {'user-agent': ModelScopeConfig.get_user_agent()} | |||||
| params = {"Method": method, "Name": name, "CnName": cn_name} | |||||
| r = requests.post(path, params=params, headers=headers) | |||||
| r.raise_for_status() | |||||
| except Exception: | |||||
| pass | |||||
| return | return | ||||
| @@ -152,7 +152,7 @@ class Pipeline(ABC): | |||||
| **kwargs) -> Union[Dict[str, Any], Generator]: | **kwargs) -> Union[Dict[str, Any], Generator]: | ||||
| # model provider should leave it as it is | # model provider should leave it as it is | ||||
| # modelscope library developer will handle this function | # modelscope library developer will handle this function | ||||
| model_name = self.cfg.task | |||||
| model_name = self.cfg.model.type | |||||
| create_library_statistics("pipeline", model_name, None) | create_library_statistics("pipeline", model_name, None) | ||||
| # place model to cpu or gpu | # place model to cpu or gpu | ||||
| if (self.model or (self.has_multiple_models and self.models[0])): | if (self.model or (self.has_multiple_models and self.models[0])): | ||||
| @@ -437,7 +437,7 @@ class EpochBasedTrainer(BaseTrainer): | |||||
| def train(self, checkpoint_path=None, *args, **kwargs): | def train(self, checkpoint_path=None, *args, **kwargs): | ||||
| self._mode = ModeKeys.TRAIN | self._mode = ModeKeys.TRAIN | ||||
| model_name = self.cfg.task | |||||
| model_name = self.cfg.model.type | |||||
| create_library_statistics("train", model_name, None) | create_library_statistics("train", model_name, None) | ||||
| if self.train_dataset is None: | if self.train_dataset is None: | ||||
| @@ -459,7 +459,7 @@ class EpochBasedTrainer(BaseTrainer): | |||||
| self.train_loop(self.train_dataloader) | self.train_loop(self.train_dataloader) | ||||
| def evaluate(self, checkpoint_path=None): | def evaluate(self, checkpoint_path=None): | ||||
| model_name = self.cfg.task | |||||
| model_name = self.cfg.model.type | |||||
| create_library_statistics("evaluate", model_name, None) | create_library_statistics("evaluate", model_name, None) | ||||
| if checkpoint_path is not None and os.path.isfile(checkpoint_path): | if checkpoint_path is not None and os.path.isfile(checkpoint_path): | ||||
| from modelscope.trainers.hooks import CheckpointHook | from modelscope.trainers.hooks import CheckpointHook | ||||