Feat: add model source for aigc model (#1530)

This commit is contained in:
Xingjun.Wang
2025-10-27 17:19:34 +08:00
committed by GitHub
parent da5bef7929
commit ad4867d783
3 changed files with 29 additions and 13 deletions

View File

@@ -122,6 +122,13 @@ class CreateCMD(CLICommand):
type=str,
default='',
help='Path in the repository to upload to.')
aigc_group.add_argument(
'--model_source',
type=str,
default='USER_UPLOAD',
help=
'Source of the AIGC model. `USER_UPLOAD`, `TRAINED_FROM_MODELSCOPE` or `TRAINED_FROM_ALIYUN_FC`.'
)
parser.set_defaults(func=subparser_func)
@@ -179,10 +186,11 @@ class CreateCMD(CLICommand):
model_path=self.args.model_path,
aigc_type=self.args.aigc_type,
base_model_type=self.args.base_model_type,
revision=self.args.revision,
tag=self.args.revision,
description=self.args.description,
base_model_id=self.args.base_model_id,
path_in_repo=self.args.path_in_repo,
model_source=self.args.model_source,
)
# Convert visibility string to int for the API call

View File

@@ -303,6 +303,7 @@ class HubApi:
'WeightsSize': aigc_model.weight_size,
'ModelPath': aigc_model.model_path,
'TriggerWords': aigc_model.trigger_words,
'ModelSource': aigc_model.model_source,
})
if aigc_model.official_tags:

View File

@@ -69,17 +69,20 @@ class AigcModel:
'main-strong', 'character-strong'
}
def __init__(self,
aigc_type: str,
base_model_type: str,
model_path: str,
base_model_id: str = '',
tag: Optional[str] = 'v1.0',
description: Optional[str] = 'this is an aigc model',
cover_images: Optional[List[str]] = None,
path_in_repo: Optional[str] = '',
trigger_words: Optional[List[str]] = None,
official_tags: Optional[List[str]] = None):
def __init__(
self,
aigc_type: str,
base_model_type: str,
model_path: str,
base_model_id: str = '',
tag: Optional[str] = 'v1.0',
description: Optional[str] = 'this is an aigc model',
cover_images: Optional[List[str]] = None,
path_in_repo: Optional[str] = '',
trigger_words: Optional[List[str]] = None,
official_tags: Optional[List[str]] = None,
model_source: Optional[str] = 'USER_UPLOAD',
):
"""
Initializes the AigcModel helper.
@@ -94,12 +97,15 @@ class AigcModel:
path_in_repo (str, optional): Path in the repository.
trigger_words (List[str], optional): Trigger words for the AIGC Lora model.
official_tags (List[str], optional): Official tags for the AIGC model. Defaults to None.
model_source (str, optional): Source of the model.
`USER_UPLOAD`, `TRAINED_FROM_MODELSCOPE` or `TRAINED_FROM_ALIYUN_FC`. Defaults to 'USER_UPLOAD'.
"""
self.model_path = model_path
self.aigc_type = aigc_type
self.base_model_type = base_model_type
self.tag = tag
self.description = description
self.model_source = model_source
# Process cover images - convert local paths to base64 data URLs
if cover_images is not None:
processed_cover_images = []
@@ -383,7 +389,8 @@ class AigcModel:
'weight_sha256': self.weight_sha256,
'weight_size': self.weight_size,
'trigger_words': self.trigger_words,
'official_tags': self.official_tags
'official_tags': self.official_tags,
'model_source': self.model_source,
}
@classmethod