Skip to content

Commit ad4867d

Browse files
Feat: add model source for aigc model (modelscope#1530)
1 parent da5bef7 commit ad4867d

3 files changed

Lines changed: 29 additions & 13 deletions

File tree

modelscope/cli/create.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ def define_args(parsers: _SubParsersAction):
122122
type=str,
123123
default='',
124124
help='Path in the repository to upload to.')
125+
aigc_group.add_argument(
126+
'--model_source',
127+
type=str,
128+
default='USER_UPLOAD',
129+
help=
130+
'Source of the AIGC model. `USER_UPLOAD`, `TRAINED_FROM_MODELSCOPE` or `TRAINED_FROM_ALIYUN_FC`.'
131+
)
125132

126133
parser.set_defaults(func=subparser_func)
127134

@@ -179,10 +186,11 @@ def _create_aigc_model(self):
179186
model_path=self.args.model_path,
180187
aigc_type=self.args.aigc_type,
181188
base_model_type=self.args.base_model_type,
182-
revision=self.args.revision,
189+
tag=self.args.revision,
183190
description=self.args.description,
184191
base_model_id=self.args.base_model_id,
185192
path_in_repo=self.args.path_in_repo,
193+
model_source=self.args.model_source,
186194
)
187195

188196
# Convert visibility string to int for the API call

modelscope/hub/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ def create_model(self,
303303
'WeightsSize': aigc_model.weight_size,
304304
'ModelPath': aigc_model.model_path,
305305
'TriggerWords': aigc_model.trigger_words,
306+
'ModelSource': aigc_model.model_source,
306307
})
307308

308309
if aigc_model.official_tags:

modelscope/hub/utils/aigc.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,20 @@ class AigcModel:
6969
'main-strong', 'character-strong'
7070
}
7171

72-
def __init__(self,
73-
aigc_type: str,
74-
base_model_type: str,
75-
model_path: str,
76-
base_model_id: str = '',
77-
tag: Optional[str] = 'v1.0',
78-
description: Optional[str] = 'this is an aigc model',
79-
cover_images: Optional[List[str]] = None,
80-
path_in_repo: Optional[str] = '',
81-
trigger_words: Optional[List[str]] = None,
82-
official_tags: Optional[List[str]] = None):
72+
def __init__(
73+
self,
74+
aigc_type: str,
75+
base_model_type: str,
76+
model_path: str,
77+
base_model_id: str = '',
78+
tag: Optional[str] = 'v1.0',
79+
description: Optional[str] = 'this is an aigc model',
80+
cover_images: Optional[List[str]] = None,
81+
path_in_repo: Optional[str] = '',
82+
trigger_words: Optional[List[str]] = None,
83+
official_tags: Optional[List[str]] = None,
84+
model_source: Optional[str] = 'USER_UPLOAD',
85+
):
8386
"""
8487
Initializes the AigcModel helper.
8588
@@ -94,12 +97,15 @@ def __init__(self,
9497
path_in_repo (str, optional): Path in the repository.
9598
trigger_words (List[str], optional): Trigger words for the AIGC Lora model.
9699
official_tags (List[str], optional): Official tags for the AIGC model. Defaults to None.
100+
model_source (str, optional): Source of the model.
101+
`USER_UPLOAD`, `TRAINED_FROM_MODELSCOPE` or `TRAINED_FROM_ALIYUN_FC`. Defaults to 'USER_UPLOAD'.
97102
"""
98103
self.model_path = model_path
99104
self.aigc_type = aigc_type
100105
self.base_model_type = base_model_type
101106
self.tag = tag
102107
self.description = description
108+
self.model_source = model_source
103109
# Process cover images - convert local paths to base64 data URLs
104110
if cover_images is not None:
105111
processed_cover_images = []
@@ -383,7 +389,8 @@ def to_dict(self) -> dict:
383389
'weight_sha256': self.weight_sha256,
384390
'weight_size': self.weight_size,
385391
'trigger_words': self.trigger_words,
386-
'official_tags': self.official_tags
392+
'official_tags': self.official_tags,
393+
'model_source': self.model_source,
387394
}
388395

389396
@classmethod

0 commit comments

Comments
 (0)