zixaphir / Stable-Diffusion-Webui-Civitai-Helper

Stable Diffusion Webui Extension for Civitai, to manage your model much more easily.
198 stars 25 forks source link

[BUG] Model Description & username should be stored #8

Closed JingJang closed 1 year ago

JingJang commented 1 year ago

In a lot of Civitai models, the model description contains extra trigger word and necessary information. Currently this information is not stored (movelVersion description is stored only).

If feature is implemented, it needs to auto-update all info files if model version still exists.

(I changed it to bug as it really is a necessary feature due to the fact many models have the triggers only in the model description)

Also username of author.

zixaphir commented 1 year ago

I don't think I understand. Currently model description is saved as the description in [model_name].json, along with version information as part of the Notes section. If you are talking about the [model_name].civitai.info, I honestly am considering trying to eliminate that file. WebUI 1.5 introduced a clean metadata interface that allows the average user to view model details within the UI, provided they add them, and I'm more interested in providing that data and facilitating usage of that UI than having users dig around in obtuse json files

JingJang commented 1 year ago

I was hoping you were going to start saving the information in the json file.

First reason for saving author, is sometimes the model is removed, but if you have the creator username you can still find other works of his if you like his work.

As to the description. Here is an example of what I mean. Not the best illustration but it gives you an idea.

So for model 128877 version 141166 https://civitai.com/models/128877, the API returns as follows:

https://civitai.com/api/v1/models/128877 https://civitai.com/api/v1/model-versions/141166

Currently the model version API json is saved. If you look at the description in the JSON, it is null while the trainwords are:

However if you look at https://civitai.com/api/v1/models/128877 the description has a list of other trigger words:

This is used to often by a lot of people. as it just quicker to type it in the model description than to type in trigger words and it can be shared across all model versions.

Another model example is https://civitai.com/models/92778. The trigger words can only be found in the model description. You can see the version description is only: Retrained from zero on 11 concepts, though, not all of them were learned well

While the model description (html format), which contains the trigger words, is:

'<p>LoRA for expanding available pool of emotions of character.</p><h1 id="heading-895">V2 info:</h1><p>Trigger word - "<strong>eexpr"</strong></p><p>All preview images were generated on <a target="_blank" rel="ugc" href="https://civitai.com/models/95587/divineanimemix">DivineAnimeMix</a> and clip 1.</p><p>Recommended lora weight: 0.75-1.</p><p>Expression words sometimes must be used with more weight (like 1.1-1.2)</p><p></p><h2 id="heading-896">Well working expressions:</h2><pre><code>embarrassed, evil smile, smile, constricted pupils, half-closed eyes, wavy mouth, shaded face, disgusted</code></pre><p></p><h2 id="heading-897">Somewhat working (in order to get to work, must be used with other triggers):</h2><pre><code>gesugao, shocked, scared</code></pre><p>Example prompts you can find in <a target="_blank" rel="ugc" href="https://civitai.com/posts/342488">Preview images</a>.</p><p></p><h3 id="heading-898">Trained on 294 images of next content:</h3><ul><li><p>constricted pupils - 71 images</p></li><li><p>gesugao - 25 images</p></li><li><p>wavy mouth - 25 images</p></li><li><p>disgusted - 21 image</p></li><li><p>embarrassed - 23 images</p></li><li><p>evil smile - 21 image</p></li><li><p>expressionless - 21 image</p></li><li><p>scared - 21 image</p></li><li><p>shocked - 22 images</p></li><li><p>smirk - 21 image</p></li><li><p>smug - 23 images</p></li></ul><p></p><p>Currently being tested on other models and clipskip levels.</p><p></p><p>V1 info:</p><p>Supported expressions:</p><p>bored, angry, embarrassed, expressionless, dead eyes, empty eyes, blush, full face blush, smirk, smug, smile, wide smile, evil smile, grin, constricted pupils, sweating, surprised, shocked, wavy mouth, dot mouth, half-closed eyes and some more.</p><p></p><p>Better be used in ADetailer with weight of 0.5-0.8 and can be used in general rendering at weight 0.3-0.5.</p><p></p><p>All prompts you can find in images attached to preview.<br />All images provided was upscaled via highres fix 2x and passed through ADetailer.<br /></p><p>Would love to see reasonable criticism and any recommendations!</p>'

zixaphir commented 1 year ago

That info is currently already appended to the JSON @ https://github.com/zixaphir/Stable-Diffusion-Webui-Civitai-Helper/blob/6912d5f655020d486363c65275d90d85edf0007f/scripts/ch_lib/civitai.py#L37-L50 whenever we're relying on https://civitai.com/api/v1/model-versions/[id], https://github.com/zixaphir/Stable-Diffusion-Webui-Civitai-Helper/blob/6912d5f655020d486363c65275d90d85edf0007f/scripts/ch_lib/civitai.py#L184-L210

zixaphir commented 1 year ago

Also, I'm not sure why the creator is not being fetched. The API is supposed to provide it and outside doing some field sanitizing and the changes in the above comment, we save the fetched JSON as is.

JingJang commented 1 year ago

It must have been done with an update as I have lots of .info files showing that isn't the case. Can you consider adding a way of updating all info files if they are still online.

As to the creator credentials, the version JSON does not contain that information. It must be appended from the model JSON, and it does not seem to do that from the code shown above.

One more thing, shouldn't the extra information be stored in the current model property. So:

"model": {
        "name": "Expanded Expressions - Concept",
        "type": "LORA",
        "nsfw": false,
        "poi": false
    },

would become

"model": {
        "name": "Expanded Expressions - Concept",
        "type": "LORA",
        "nsfw": false,
        "poi": false        
        "description":  "blah blah blah"
        "allowNoCredit": true,
        "allowCommercialUse": "Image",
        "allowDerivatives": true,
        "allowDifferentLicense": false
    }

This way you do not rename version description to "version info" and you keep the original version JSON structure intact.

Thank you for keeping this addon alive.

zixaphir commented 1 year ago

Yeah, I'm fine with that change. I can append creator info and move ""version info"" into the model property as its description.

Also the info files are now versioned as of my last update, so now I'm more comfortable making breaking changes since I can just check the version in the file and write compatibility code as needed.

JingJang commented 1 year ago

... move ""version info"" into the model property as its description.

No, it's the other way around. "version info" remains as "description" and the data that you get from the model's JSON goes into the model property.

Currently it moves the "description" property in the version's JSON to "version info" and then imports the description, allowNoCredit, etc. from the model's JSON into the root of the version's JSON.

zixaphir commented 1 year ago

The current behavior is we fetch the metadata by version id, swap out the description for the "parent" description, and move the previous description to the version info.

The new behavior will be that we fetch the "parent" data and append it all into the model metadata, including the "parent" description. The original description under the root of the JSON remains unchanged.

https://github.com/zixaphir/Stable-Diffusion-Webui-Civitai-Helper/commit/cdc33bdf818d1b42e4a8c124a5ac1effc885a5a6

Additionally, creator information is appended to the root: https://github.com/zixaphir/Stable-Diffusion-Webui-Civitai-Helper/commit/a116da6de92744888f663afa29ac228e1b86e589

zixaphir commented 1 year ago

should be complete as of v1.7.2