diff --git a/modelscope/hub/utils/aigc.py b/modelscope/hub/utils/aigc.py index 0109d4ca..7be6a7c9 100644 --- a/modelscope/hub/utils/aigc.py +++ b/modelscope/hub/utils/aigc.py @@ -75,6 +75,8 @@ class AigcModel: cover_images (List[str], optional): List of cover image URLs. base_model_id (str, optional): Base model name. e.g., 'AI-ModelScope/FLUX.1-dev'. path_in_repo (str, optional): Path in the repository. + Note: Auto-upload during AIGC create is temporarily disabled by server. This parameter + will not take effect at creation time. """ self.model_path = model_path self.aigc_type = aigc_type @@ -125,6 +127,30 @@ class AigcModel: target_file = self.model_path logger.info('Using file: %s', os.path.basename(target_file)) elif os.path.isdir(self.model_path): + # Validate top-level directory: it must not be empty; and if it has files, + # they must not be only the common placeholder files + top_entries = os.listdir(self.model_path) + if len(top_entries) == 0: + raise ValueError( + f'Directory is empty: {self.model_path}. ' + f'Please place at least one model file at the top level (e.g., .safetensors/.pth/.bin).' + ) + + top_files = [ + name for name in top_entries + if os.path.isfile(os.path.join(self.model_path, name)) + ] + placeholder_names = { + '.gitattributes', 'configuration.json', 'readme.md' + } + if top_files: + normalized = {name.lower() for name in top_files} + if normalized.issubset(placeholder_names): + raise ValueError( + 'Top-level directory contains only [.gitattributes, configuration.json, README.md]. ' + 'Please place additional model files at the top level (e.g., .safetensors/.pth/.bin).' + ) + # Priority order for metadata file: safetensors -> pth -> bin -> first file file_extensions = ['.safetensors', '.pth', '.bin'] target_file = None