Request for ModelSpec

#19
by AlexGoodwin - opened

Hi, ModelSpec https://github.com/Stability-AI/ModelSpec is used to easily identify key data about singlefile models, and is missing from your SSD-1B.safetensors model - this means that, keywise, it will be assumed by parsers to be an SDXL 0.9 Preview model (as it matches the SDXL keys, but lacks the SDXL 1.0 ModelSpec metadata nor its own metadata).

For example, here's how SSD-1B looks next to the SDXL 1.0 models in StableSwarmUI's model browser:

image.png

So I'm requesting that you add ModelSpec metadata. Probably the 'modelspec.architecture' key should be 'segmind-stable-diffusion-1b'.

I'm happy to provide more information if needed.

Segmind org

Hi, The Singlefile has been generated via this script. Could you provide me with the way to proceed to generate the ModelSpec? An example would be very helpful!

There's sample code to add it with the HF Safetensors code here: https://github.com/Stability-AI/ModelSpec/blob/master/examples/python/example_hf_safetensors.py that you can call before the save_file at the end of that script. You can ignore most of that file, as the actual part that matters is just the metadata input to the save_file call -- you have save_file(state_dict, args.checkpoint_path), just change that to save_file(state_dict, args.checkpoint_path, metadata=metadata)

Where metadata is defined something like so:

metadata = {
    # === Must ===
    "modelspec.sai_model_spec": "1.0.0", # Required version ID for the spec
    "modelspec.architecture": "segmind-stable-diffusion-1b", # Architecture, reference the ID of the original model of the arch to match the ID
    "modelspec.implementation": "https://github.com/segmind/SSD-1B",
    "modelspec.title": "Segmind Stable Diffusion 1B (SSD-1B)", # Clean, human-readable title. May use your own phrasing/language/etc
    # === Should ===
    "modelspec.author": "Segmind", # Your name or company name
    "modelspec.description": "The Segmind Stable Diffusion Model (SSD-1B) is a distilled 50% smaller version of the Stable Diffusion XL (SDXL), offering a 60% speedup while maintaining high-quality text-to-image generation capabilities. It has been trained on diverse datasets, including Grit and Midjourney scrape data, to enhance its ability to create a wide range of visual content based on textual prompts. This model employs a knowledge distillation strategy, where it leverages the teachings of several expert models in succession, including SDXL, ZavyChromaXL, and JuggernautXL, to combine their strengths and produce impressive visual outputs.", # Describe the model in your own words/language/etc. Focus on what users need to know
    "modelspec.date": "2023-10-24", # ISO-8601 compliant date of when the model was created
    # === Can ===
    "modelspec.license": "Apache 2.0" # eg CreativeML Open RAIL, etc.
}
Segmind org

Thanks for the information! I will add it.

Segmind org

I have added it here please let me know if any changes are required.

That's perfect! Awesome! Only thing left would be to remove the non-modelspec'd copy of the model to avoid confusion when downloading.

Segmind org

Would the ModelSpec version work with all the other frameworks such as Comfy and A11?

Yes, ModelSpec is explicitly designed to always be compatible, even with tools that aren't aware of ModelSpec (as it's all stored in the metadata)

(Also both ComfyUI and AutoWebUI are explicitly aware of ModelSpec, albeit not necessarily making full use of it in the way Swarm does)

Sign up or log in to comment