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

If the model is archived, an error occurs #92

Closed yeungmozhu closed 2 months ago

yeungmozhu commented 3 months ago

If the model is archived, the following error occurs:

GET Request failed with error code: 404: Not Found Traceback (most recent call last): File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict output = await app.get_blocks().process_api( File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api result = await self.call_function( File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1117, in call_function prediction = await utils.async_iteration(iterator) File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\gradio\utils.py", line 350, in async_iteration return await iterator.anext() File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\gradio\utils.py", line 343, in anext return await anyio.to_thread.run_sync( File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\anyio_backends_asyncio.py", line 807, in run result = context.run(func, args) File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\gradio\utils.py", line 326, in run_sync_iterator_async return next(iterator) File "D:\SDLocal\stable-diffusion-webui\venv\lib\site-packages\gradio\utils.py", line 695, in gen_wrapper yield from f(args, **kwargs) File "D:\SDLocal\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\scripts\ch_lib\model_action_civitai.py", line 162, in scan_model for result in scan_single_model(filepath, model_type, refetch_old, delay): File "D:\SDLocal\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\scripts\ch_lib\model_action_civitai.py", line 90, in scan_single_model model_info = civitai.get_model_info_by_hash(sha256_hash) File "D:\SDLocal\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\scripts\ch_lib\civitai.py", line 126, in get_model_info_by_hash content = append_parent_model_metadata(content) File "D:\SDLocal\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\scripts\ch_lib\civitai.py", line 95, in append_parent_model_metadata content["creator"] = parent_model.get("creator", "{}") AttributeError: 'NoneType' object has no attribute 'get'

zixaphir commented 3 months ago

Can you include the URL of an archived model?

yeungmozhu commented 3 months ago

Can you include the URL of an archived model?

https://civitai.com/models/283867/dva-dlc

CHv1.8.3: Creating model info for: D.VA DLC .safetensors CHv1.8.3: model action sha256: 00b48ef4d6a2610441208dc2e66868aad59a411ed186752957643879c98fd88f CHv1.8.3: Request model info from civitai CHv1.8.3: Fetching Parent Model Information CHv1.8.3: Request model info from civitai: 283867 CHv1.8.3: GET Request failed with error code: 404: Not Found

ride5k commented 3 months ago

similar issue with https://civitai.com/models/375252

zixaphir commented 2 months ago

Unfortunately it appears that the API does not allow accessing archived models, so there's nothing I can really do about this. You can try asking the devs of Civitai to expose metadata for archived models.

armourking commented 2 months ago

Fail gracefully with a placeholder so the scan can continue?

zixaphir commented 2 months ago

Fail gracefully with a placeholder so the scan can continue?

Sorry, you are correct. Sometimes my head is so in the weeds that I miss the forest for the trees

AugmentedRealityCat commented 2 months ago

EDIT: I tried the latest DEV branch and the problem remains. I thought there was a chance it would work because of this fix posted yesterday, but it's not covering the specific case of archived models: https://github.com/zixaphir/Stable-Diffusion-Webui-Civitai-Helper/commit/05c00ffb37b02e6a318aefe88d6b1d06886ab499

Just to provide one more example, here is my own log for this error (that was prior to testing the DEV branch) :

CHv1.8.3: Creating model info for: 0299 New York City Police Department_v1.safetensors
CHv1.8.3: model action sha256: 002262e1d30e6d3622769f8ed0332d38a0898029dc04cd3954c21a94435c7357
CHv1.8.3: Request model info from civitai
CHv1.8.3: Fetching Parent Model Information
CHv1.8.3: Request model info from civitai: 333806
CHv1.8.3: GET Request failed with error code:
   404: Not Found
Traceback (most recent call last):
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\gradio\blocks.py", line 1117, in call_function
    prediction = await utils.async_iteration(iterator)
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\gradio\utils.py", line 350, in async_iteration
    return await iterator.__anext__()
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\gradio\utils.py", line 343, in __anext__
    return await anyio.to_thread.run_sync(
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\gradio\utils.py", line 326, in run_sync_iterator_async
    return next(iterator)
  File "C:\stable-diffusion-webui\venvopt\lib\site-packages\gradio\utils.py", line 695, in gen_wrapper
    yield from f(*args, **kwargs)
  File "C:\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\ch_lib\model_action_civitai.py", line 162, in scan_model
    for result in scan_single_model(filepath, model_type, refetch_old, delay):
  File "C:\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\ch_lib\model_action_civitai.py", line 90, in scan_single_model
    model_info = civitai.get_model_info_by_hash(sha256_hash)
  File "C:\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\ch_lib\civitai.py", line 126, in get_model_info_by_hash
    content = append_parent_model_metadata(content)
  File "C:\stable-diffusion-webui\extensions\Stable-Diffusion-Webui-Civitai-Helper\ch_lib\civitai.py", line 95, in append_parent_model_metadata
    content["creator"] = parent_model.get("creator", "{}")
AttributeError: 'NoneType' object has no attribute 'get'
zixaphir commented 2 months ago

The work done yesterday is unrelated to this issue and only affects the model downloader. I have not been on my PC today to so I haven't been able to work on resolving this yet

AugmentedRealityCat commented 2 months ago

The https://github.com/zixaphir/Stable-Diffusion-Webui-Civitai-Helper/commit/25a0dacd68050fff216a5cfcfb0be42dc0576978 fix works very well for me ! Thanks a lot @zixaphir for your quick intervention - you provide better customer support than many big corporations charging us monthly fees to use their tools !