BlafKing / sd-civitai-browser-plus

Extension to access CivitAI via WebUI: download, delete, scan for updates, list installed models, assign tags, and boost downloads with multi-threading.
GNU Affero General Public License v3.0
309 stars 53 forks source link

[Bug]: local variable 'model_file' referenced before assignment when loading info on dev branch #197

Closed silveroxides closed 7 months ago

silveroxides commented 8 months ago

Describe the bug.

As title, when trying to load info in the txt2img or img2img tab of for example a Lora it just does nothing but an error is produced in console

Steps to reproduce the problem.

  1. Start webui on dev branch
  2. open lora selection menu with the preview cards
  3. press the civitai browser plus button
  4. get overlay
  5. ... nothing more
  6. check logs

Expected behavior

I assume info should be shown though yet to experience it

System info

Console logs

Traceback (most recent call last):
  File "D:\stable-diffusion-webui\system\python\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\stable-diffusion-webui\system\python\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "D:\stable-diffusion-webui\system\python\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "D:\stable-diffusion-webui\system\python\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "D:\stable-diffusion-webui\system\python\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "D:\stable-diffusion-webui\system\python\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "D:\stable-diffusion-webui\system\python\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "D:\stable-diffusion-webui\webui\extensions\sd-civitai-browser-plus\scripts\civitai_file_manage.py", line 377, in model_from_sent
    modelID = get_models(model_file, True)
UnboundLocalError: local variable 'model_file' referenced before assignment
2024-02-10 02:39:07 INFO [httpx] HTTP Request: POST http://localhost:7860/api/predict "HTTP/1.1 500 Internal Server Error"

Additional information

No response

BlafKing commented 8 months ago

Thanks for reporting! The error:

UnboundLocalError: local variable 'model_file' referenced before assignment

indicates that the extensions was unable to find the path of the selected model, not exactly sure what could cause this, as I can't recreate any issues with how it's currently implemented.

However, since you're using the dev branch, that version should now include a button on the model cards which can be used to copy/grab the model path directly, so I've published an update which checks for it's existence, and if it exists, uses the path provided there which should hopefully solve your issue, since it should now use the path directly provided by SD-WebUI.

I've also added some additional error logs if it fails to find the copy path model card button, which should give me more insight.

Please let me know if the latest commit fixes your issue! :)

BlafKing commented 7 months ago

Looks like the issue was likely caused by the usage of symlinks, I'll make sure to include a fix for this in the next update!

BlafKing commented 7 months ago

This issue should now be fixed, I'll go and close this issue.

Do feel free to send another message here if the issue is still present!