49
49
)
50
50
from diffusers .optimization import get_scheduler
51
51
from diffusers .utils import check_min_version , is_wandb_available
52
+ from diffusers .utils .hub_utils import load_or_create_model_card , populate_model_card
52
53
from diffusers .utils .import_utils import is_xformers_available
53
54
from diffusers .utils .torch_utils import is_compiled_module
54
55
@@ -195,7 +196,7 @@ def import_model_class_from_model_name_or_path(
195
196
raise ValueError (f"{ model_class } is not supported." )
196
197
197
198
198
- def save_model_card (repo_id : str , image_logs = None , base_model = str , repo_folder = None ):
199
+ def save_model_card (repo_id : str , image_logs : dict = None , base_model : str = None , repo_folder : str = None ):
199
200
img_str = ""
200
201
if image_logs is not None :
201
202
img_str = "You can find some example images below.\n "
@@ -209,27 +210,25 @@ def save_model_card(repo_id: str, image_logs=None, base_model=str, repo_folder=N
209
210
image_grid (images , 1 , len (images )).save (os .path .join (repo_folder , f"images_{ i } .png" ))
210
211
img_str += f"\n "
211
212
212
- yaml = f"""
213
- ---
214
- license: creativeml-openrail-m
215
- base_model: { base_model }
216
- tags:
217
- - stable-diffusion-xl
218
- - stable-diffusion-xl-diffusers
219
- - text-to-image
220
- - diffusers
221
- - t2iadapter
222
- inference: true
223
- ---
224
- """
225
- model_card = f"""
213
+ model_description = f"""
226
214
# t2iadapter-{ repo_id }
227
215
228
216
These are t2iadapter weights trained on { base_model } with new type of conditioning.
229
217
{ img_str }
230
218
"""
231
- with open (os .path .join (repo_folder , "README.md" ), "w" ) as f :
232
- f .write (yaml + model_card )
219
+ model_card = load_or_create_model_card (
220
+ repo_id_or_path = repo_id ,
221
+ from_training = True ,
222
+ license = "creativeml-openrail-m" ,
223
+ base_model = base_model ,
224
+ model_description = model_description ,
225
+ inference = True ,
226
+ )
227
+
228
+ tags = ["stable-diffusion-xl" , "stable-diffusion-xl-diffusers" , "text-to-image" , "diffusers" , "t2iadapter" ]
229
+ model_card = populate_model_card (model_card , tags = tags )
230
+
231
+ model_card .save (os .path .join (repo_folder , "README.md" ))
233
232
234
233
235
234
def parse_args (input_args = None ):
0 commit comments