(repo_id: str, image_logs=None, base_model=str, repo_folder=None)
| 214 | |
| 215 | |
| 216 | def save_model_card(repo_id: str, image_logs=None, base_model=str, repo_folder=None): |
| 217 | img_str = "" |
| 218 | if image_logs is not None: |
| 219 | img_str = "You can find some example images below.\n\n" |
| 220 | for i, log in enumerate(image_logs): |
| 221 | images = log["images"] |
| 222 | validation_prompt = log["validation_prompt"] |
| 223 | validation_image = log["validation_image"] |
| 224 | validation_image.save(os.path.join(repo_folder, "image_control.png")) |
| 225 | img_str += f"prompt: {validation_prompt}\n" |
| 226 | images = [validation_image] + images |
| 227 | image_grid(images, 1, len(images)).save(os.path.join(repo_folder, f"images_{i}.png")) |
| 228 | img_str += f"\n" |
| 229 | |
| 230 | model_description = f""" |
| 231 | # SD3 controlnet-{repo_id} |
| 232 | |
| 233 | These are controlnet weights trained on {base_model} with new type of conditioning. |
| 234 | The weights were trained using [ControlNet](https://github.com/lllyasviel/ControlNet) with the [SD3 diffusers trainer](https://github.com/huggingface/diffusers/blob/main/examples/controlnet/README_sd3.md). |
| 235 | {img_str} |
| 236 | |
| 237 | Please adhere to the licensing terms as described `[here](https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/LICENSE)`. |
| 238 | """ |
| 239 | model_card = load_or_create_model_card( |
| 240 | repo_id_or_path=repo_id, |
| 241 | from_training=True, |
| 242 | license="openrail++", |
| 243 | base_model=base_model, |
| 244 | model_description=model_description, |
| 245 | inference=True, |
| 246 | ) |
| 247 | |
| 248 | tags = [ |
| 249 | "text-to-image", |
| 250 | "diffusers-training", |
| 251 | "diffusers", |
| 252 | "sd3", |
| 253 | "sd3-diffusers", |
| 254 | "controlnet", |
| 255 | ] |
| 256 | model_card = populate_model_card(model_card, tags=tags) |
| 257 | |
| 258 | model_card.save(os.path.join(repo_folder, "README.md")) |
| 259 | |
| 260 | |
| 261 | def parse_args(input_args=None): |
no test coverage detected