Sign In

Making Model page with widget in HuggingFace from standalone model file (local python)

0
Making Model page with widget in HuggingFace from standalone model file (local python)

Making T2I widget in HuggingFace from standalone model file (local python)

I'm not promoting web services! I just want make a completed model card and make the widget working as a mirror page!

Also for base checkpoint of SD1 / SD2 / SDXL only. LoRA / ControlNet / other model types is not covered in this guide yet. There will be different scripts in the wild if that's is a case. Once you get the model into diffuser, you will be fine.

Common part: First part of the model card

Self explained. Add this session, including the --- syntax in the first session. Make sure you switch between code and preview mode when editing the README.MD in the Web portal, in the root directory of the model (git) repo.

---
language:
  - en
license: creativeml-openrail-m
tags:
  - stable-diffusion
  - stable-diffusion-diffusers
  - text-to-image
  - safetensors
  - merge
inference: true
thumbnail: >-
  https://localhost/your-preview.jpg
widget:
  - text: "1boy, astolfo"
example_title: "Example"
library_name: diffusers
---

# Model title here. #

Continue your original model description.

SD1.5: Using HuggingFace's script

My SD1.5 model page.

Recommended to have an environment for running SD stuffs. Get convert_original_stable_diffusion_to_diffusers.py and read this command for reference:

python convert_original_stable_diffusion_to_diffusers.py --checkpoint_path="/path/to/your_sd15.safetensors" --from_safetensors --dump_path="/path/to/your_sd15/as_a_new_folder/" --half

Then upload all the generated content to your model page in HF. Make sure they are in the root directory.

SD2.1: Still using HuggingFace's script

My SD2.1 model page.

It is supported and able to detect model type in this script. However additional option is recommended:

python convert_original_stable_diffusion_to_diffusers.py --checkpoint_path="/path/to/your_sd21.safetensors" --from_safetensors --dump_path="/path/to/your_sd21/as_a_new_folder/" --half --upcast_attention

SDXL: Using third party script

My SDXL model page.

This time use convert_sdxl_to_diffusers.py instead. Place the script in the root directory of cloned kohya-ss/sd-scripts. This time it will save as model_path/model_name/ in the same directory of the model file.

python convert_sdxl_to_diffusers.py --save_precision_as=fp16 --model_to_load="/path/to/your_sdxl.safetensors"

Good luck!

For Colab versions, you can check out this article created by other chads.

0

Comments