zixaphir / Stable-Diffusion-Webui-Civitai-Helper

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

Scan Models for Civitai: finds older version of model when duplicate versions exist on Civitai #102

Open MisterSeajay opened 2 months ago

MisterSeajay commented 2 months ago

Describe Issue

I have downloaded the South of the Border Style embedding. On the model page in Civitai there are two versions of this, listed as V1 and SD 1.5 V1. These two versions are identical (I have downloaded and checked the hashes for each) but have different ids (30964 and 30824 respectively).

The civitai.info file for the model identifies the copy in my embeddings folder as the older one, i.e. id: 30824:

{
    "id": 30824,
    "modelId": 25749,
    "name": "SD 1.5 V1",
    "createdAt": "2023-03-28T18:22:55.996Z",
    "updatedAt": "2023-03-30T16:36:38.948Z",
    "status": "Published",
    "publishedAt": "2023-03-28T18:22:55.996Z",
    "trainedWords": [
        "southofthebordersd15"
    ],
    etc.

Issue 1

When retrieving model data from Civitai using Scan Models for Civitai it hashes the local file and then presumably searches for this on Civitai; it seems that the metadata from the oldest (first?) match is being used to populate the civitai.info file. Perhaps this is a limitation of the Civitai API.

Issue 2

When I check for updates, Civitai Helper tells me that there is a newer version available. Of course, downloaded the newer version and copying over the existing one makes no difference as the older Id is still in the .info file.

Workaround

Using the Get Model Info from Civitai by URL feature does allow you to get a .civitai.info file for the newer ID, by specifying the modelVersionId in the Civitai URL field.

I guess this could be added to the documentation as a known error / workaround?

Console log's msg or screenshot for function issue

CHv1.8.4: Request model info from civitai: 25749
CHv1.8.4: Compare version id, local: 30824, remote: 30964
CHv1.8.4: Searching local model by version id
CHv1.8.4: folder: S:\GenAI\ImageGen\data\models\embeddings\styles
CHv1.8.4: model_ids: {'model': 25749, 'version': 30964}
MisterSeajay commented 2 months ago

OK, I confirmed my hunch. When searching Civitai for the hash of this file it only returns one result, which is for the older version of this model; I guess that's not CH's fault!

https://civitai.com/api/v1/model-versions/by-hash/9FE3116C0BAB18B520A8DA1BC90FDF031D1B390C75F1139D31BA8FD4507E2F9C