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]: UnboundLocalError: local variable 'api_response' referenced before assignment #155

Closed invideot01 closed 9 months ago

invideot01 commented 9 months ago

Describe the bug.

When Laura, Checkpoint and etc. tries to scan, she gives an error, there is no Anti-Virus, and the firewall is configured to allow traffic for aria2.exe.

Steps to reproduce the problem.

  1. Go to Civitai Browser+
  2. Go to Update Models
  3. Check the "Scan for: Lora"
  4. Press button Updating model info&tags
  5. Error

Expected behavior

Everything should work correctly and start downloading information and tags from Civitai. (file.json)

System info

Console logs

K:\StableDif>git pull
Already up to date.
venv "k:\StableDif\venv\Scripts\Python.exe"
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Version: v1.7.0
Commit hash: cf2772fab0af5573da775e7437e6acdca424f26e
Faceswaplab : Use GPU requirements
Checking faceswaplab requirements
0.007752000000436965
ReActor preheating... Device: CUDA
Launching Web UI with arguments: --theme=dark --opt-sdp-no-mem-attention --no-half-vae --xformers
Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu.
WARNING ⚠️ user config directory 'tmp\AppData\Roaming\Ultralytics' is not writeable, defaulting to '/tmp' or CWD.Alternatively you can define a YOLO_CONFIG_DIR environment variable for this path.
[-] ADetailer initialized. version: 23.9.2, num models: 17
CivitAI Browser+: Aria2 RPC started
2024-01-04 16:25:40,651 - ControlNet - INFO - ControlNet v1.1.422
ControlNet preprocessor location: K:\StableDif\extensions\sd-webui-controlnet\annotator\downloads
2024-01-04 16:25:40,822 - ControlNet - INFO - ControlNet v1.1.422
sd-webui-prompt-all-in-one background API service started successfully.
16:25:41 - ReActor - STATUS - Running v0.5.1-b4
Loading weights [87ad6c9624] from K:\StableDif\models\Stable-diffusion\SD\aimaginationEvolved_v10.safetensors
2024-01-04 16:25:42,743 - AnimateDiff - INFO - Hacking i2i-batch.
Creating model from config: K:\StableDif\configs\v1-inference.yaml
*Deforum ControlNet support: enabled*
Applying attention optimization: xformers... done.
No Image data blocks found.
No Image data blocks found.
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 30.9s (prepare environment: 6.9s, import torch: 4.0s, import gradio: 0.9s, setup paths: 0.9s, initialize shared: 0.2s, other imports: 0.7s, setup codeformer: 0.3s, list SD models: 0.7s, load scripts: 7.0s, create ui: 7.2s, gradio launch: 0.6s, app_started_callback: 1.3s).
Model loaded in 9.2s (load weights from disk: 1.0s, create model: 0.7s, apply weights to model: 2.2s, load textual inversion embeddings: 3.8s, calculate empty prompt: 1.4s).
Traceback (most recent call last):
  File "k:\StableDif\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "k:\StableDif\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "k:\StableDif\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "k:\StableDif\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "k:\StableDif\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "k:\StableDif\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "k:\StableDif\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "K:\StableDif\extensions\sd-civitai-browser-plus-main\scripts\civitai_file_manage.py", line 785, in file_scan
    api_response['items'] = all_items
UnboundLocalError: local variable 'api_response' referenced before assignment

Additional information

On SD-WebUI version: 1.6.1 and Extension version: 2.1.0 all working good.

CesarCruzUtec commented 9 months ago

I get the same error while trying to update. Search and download works OK


Traceback (most recent call last):
  File "D:\IA\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\IA\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "D:\IA\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "D:\IA\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:\IA\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "D:\IA\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "D:\IA\stable-diffusion-webui\venv\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "D:\IA\stable-diffusion-webui\extensions\sd-civitai-browser-plus\scripts\civitai_file_manage.py", line 785, in file_scan
    api_response['items'] = all_items
UnboundLocalError: local variable 'api_response' referenced before assignment```
tiphae commented 9 months ago

Same since yesterday or so - search and download work okay, but all of the updates give an API timeout with the "api_response before assignment" errors shown above.

BlafKing commented 9 months ago

Thanks for reporting!

I've attempted to implement a fix in the latest version (v3.2.2)

Please let me know if the issue still exists! :)

BlafKing commented 9 months ago

I'll go ahead and set this bug report to resolved since there have been no reports for a while, please feel free to post another message here if you still experience issues! :)