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
289 stars 44 forks source link

[Bug]: extension only works the first time its intalled. #272

Closed BurntAvocadoToast closed 2 months ago

BurntAvocadoToast commented 3 months ago

Describe the bug.

using a1111, sdwebui, on runpod A40, I install the extension and restart A1111. it works well! the next time i start SD it just shows error in all the fields in webui a1111 when i try to browse content with the extension. this happens every time i try to load the extension on every install I have tried, it only works the first time and then breaks. it sucks because its the best way to get content from civitai and i desperately want it to work.

I can't be alone in this problem, and I hope there is a known fix I can apply, Thanks!

K

Steps to reproduce the problem.

  1. start a1111 stable diffusion webui on runpod A40 with Fast Stable Diffusion deployed.
  2. install civitai browser+ extension
  3. restart webui
  4. use civitai browser+ extension - it works well
  5. end session, shut down pod.
  6. new session, start A1111 sable diffusion webui on runpod A40 with Fast Stable Diffusion deployed.
  7. attempt to use civitai browser+ extension - it does not work, [Error] appears in all fields
  8. Despair.

Expected behavior

It should work every time webui is started if installed, it does not.

System info

Console logs

CHv1.8.4: Get Custom Model Folder
*** Error loading script: sd-TemporalKit-UI.py
    Traceback (most recent call last):
      File "/workspace/sd/stable-diffusion-webui/modules/scripts.py", line 508, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "/workspace/sd/stable-diffusion-webui/modules/script_loading.py", line 14, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/workspace/sd/stable-diffusion-webui/extensions/TemporalKit/scripts/sd-TemporalKit-UI.py", line 23, in <module>
        from modules.ui import  create_sampler_and_steps_selection
    ImportError: cannot import name 'create_sampler_and_steps_selection' from 'modules.ui' (/workspace/sd/stable-diffusion-webui/modules/ui.py)

---
Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu.
Downloading face_yolov8n.pt: 100%|██████████| 6.23M/6.23M [00:00<00:00, 326MB/s]
Downloading face_yolov8s.pt: 100%|██████████| 22.5M/22.5M [00:00<00:00, 423MB/s]
Downloading hand_yolov8n.pt: 100%|██████████| 6.24M/6.24M [00:00<00:00, 327MB/s]
Downloading person_yolov8n-seg.pt: 100%|████| 6.78M/6.78M [00:00<00:00, 244MB/s]
Downloading person_yolov8s-seg.pt: 100%|████| 23.9M/23.9M [00:00<00:00, 373MB/s]
Downloading yolov8x-worldv2.pt: 100%|█████████| 146M/146M [00:00<00:00, 488MB/s]
[-] ADetailer initialized. version: 24.4.1, num models: 10
*** Error loading script: clip_interrogator_ext.py
    Traceback (most recent call last):
      File "/workspace/sd/stable-diffusion-webui/modules/scripts.py", line 508, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "/workspace/sd/stable-diffusion-webui/modules/script_loading.py", line 14, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/workspace/sd/stable-diffusion-webui/extensions/clip-interrogator-ext/scripts/clip_interrogator_ext.py", line 10, in <module>
        import clip_interrogator
    ModuleNotFoundError: No module named 'clip_interrogator'

---
logs_location: /workspace/sd/stable-diffusion-webui/extensions/miaoshouai-assistant/logs
*** Error loading script: main.py
    Traceback (most recent call last):
      File "/workspace/sd/stable-diffusion-webui/modules/scripts.py", line 508, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "/workspace/sd/stable-diffusion-webui/modules/script_loading.py", line 14, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/workspace/sd/stable-diffusion-webui/extensions/miaoshouai-assistant/scripts/main.py", line 4, in <module>
        from scripts.assistant.miaoshou import MiaoShouAssistant
      File "/workspace/sd/stable-diffusion-webui/extensions/miaoshouai-assistant/scripts/assistant/miaoshou.py", line 15, in <module>
        from scripts.runtime.msai_runtime import MiaoshouRuntime
      File "/workspace/sd/stable-diffusion-webui/extensions/miaoshouai-assistant/scripts/runtime/msai_runtime.py", line 13, in <module>
        import openai
    ModuleNotFoundError: No module named 'openai'

---
2024-04-16 04:33:51,713 - warnings.py [line:109] - WARNING: /workspace/sd/stable-diffusion-webui/extensions/openpose-editor/scripts/openpose/body.py:7: DeprecationWarning: Please use `gaussian_filter` from the `scipy.ndimage` namespace, the `scipy.ndimage.filters` namespace is deprecated.
  from scipy.ndimage.filters import gaussian_filter

CivitAI Browser+: Python module 'fake_useragent' has not been imported correctly, please try to restart or install it manually.
CivitAI Browser+: Python module 'ZipUnicode' has not been imported correctly, please try to restart or install it manually.
CivitAI Browser+: Aria2 RPC restarted
CivitAI Browser+: Python module 'fake_useragent' has not been imported correctly, please try to restart or install it manually.
CivitAI Browser+: Python module 'ZipUnicode' has not been imported correctly, please try to restart or install it manually.
CivitAI Browser+: Aria2 RPC restarted
2024-04-16 04:33:56,247 - warnings.py [line:109] - WARNING: <frozen importlib._bootstrap>:283: DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead

ControlNet preprocessor location: /workspace/sd/stable-diffusion-webui/extensions/sd-webui-controlnet/annotator/downloads
2024-04-16 04:33:57,057 - ControlNet - INFO - ControlNet v1.1.443
2024-04-16 04:33:57,793 - ControlNet - INFO - ControlNet v1.1.443
No module named 'dotenv'
*** Error loading script: m2m_ui.py
    Traceback (most recent call last):
      File "/workspace/sd/stable-diffusion-webui/modules/scripts.py", line 508, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "/workspace/sd/stable-diffusion-webui/modules/script_loading.py", line 14, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/workspace/sd/stable-diffusion-webui/extensions/sd-webui-mov2mov/scripts/m2m_ui.py", line 23, in <module>
        from modules.ui import (
    ImportError: cannot import name 'create_sampler_and_steps_selection' from 'modules.ui' (/workspace/sd/stable-diffusion-webui/modules/ui.py)

---
Downloading the detection model to /root/.ifnude/detector.onnx
Downloading: 139MB [00:00, 216MB/s]                                             
Downloading the classes list to /root/.ifnude/classes
Downloading: 16.0kB [00:00, 113kB/s]                                            
2024-04-16 04:34:01,913 - roop - INFO - roop v0.0.2
2024-04-16 04:34:02,086 - roop - INFO - roop v0.0.2
*** Error loading script: api_t2v.py
    Traceback (most recent call last):
      File "/workspace/sd/stable-diffusion-webui/modules/scripts.py", line 508, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "/workspace/sd/stable-diffusion-webui/modules/script_loading.py", line 14, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/workspace/sd/stable-diffusion-webui/extensions/sd-webui-text2video/scripts/api_t2v.py", line 37, in <module>
        from t2v_helpers.video_audio_utils import find_ffmpeg_binary
      File "/workspace/sd/stable-diffusion-webui/extensions/sd-webui-text2video/scripts/t2v_helpers/video_audio_utils.py", line 11, in <module>
        from mutagen.mp4 import MP4
    ModuleNotFoundError: No module named 'mutagen'

---
*** Error loading script: text2vid.py
    Traceback (most recent call last):
      File "/workspace/sd/stable-diffusion-webui/modules/scripts.py", line 508, in load_scripts
        script_module = script_loading.load_module(scriptfile.path)
      File "/workspace/sd/stable-diffusion-webui/modules/script_loading.py", line 14, in load_module
        module_spec.loader.exec_module(module)
      File "<frozen importlib._bootstrap_external>", line 883, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/workspace/sd/stable-diffusion-webui/extensions/sd-webui-text2video/scripts/text2vid.py", line 24, in <module>
        from t2v_helpers.render import run
      File "/workspace/sd/stable-diffusion-webui/extensions/sd-webui-text2video/scripts/t2v_helpers/render.py", line 5, in <module>
        from modelscope.process_modelscope import process_modelscope
      File "/workspace/sd/stable-diffusion-webui/extensions/sd-webui-text2video/scripts/modelscope/process_modelscope.py", line 20, in <module>
        from t2v_helpers.video_audio_utils import ffmpeg_stitch_video, get_quick_vid_info, vid2frames, duplicate_pngs_from_folder, clean_folder_name
      File "/workspace/sd/stable-diffusion-webui/extensions/sd-webui-text2video/scripts/t2v_helpers/video_audio_utils.py", line 11, in <module>
        from mutagen.mp4 import MP4
    ModuleNotFoundError: No module named 'mutagen'

---
Started the depthmap API. DO NOT HOST PUBLICLY - SECURITY RISKS!
[text2prompt] Following databases are available:
    all-mpnet-base-v2 : danbooru_strict
== WD14 tagger /gpu:0, uname_result(system='Linux', node='9d5c47307e7d', release='5.4.0-167-generic', version='#184-Ubuntu SMP Tue Oct 31 09:21:49 UTC 2023', machine='x86_64') ==
Loading weights [31e35c80fc] from /workspace/sd/stable-diffusion-webui/models/Stable-diffusion/sd_xl_base_1.0.safetensors
CHv1.8.4: Set Proxy: 
Creating model from config: /workspace/sd/stablediffusion/generative-models/configs/inference/sd_xl_base.yaml
2024-04-16 04:34:28,449 - ControlNet - INFO - ControlNet UI callback registered.
2024-04-16 04:34:29,104 - factory.py [line:154] - INFO: Loaded ViT-bigG-14 model config.
*Deforum ControlNet support: enabled*
[text2prompt] Loading database with name "all-mpnet-base-v2 : danbooru_strict"...
[text2prompt] Database loaded
Running on local URL: https://71ttkads86f8gc-3001.proxy.runpod.net
✔ Connected
Applying attention optimization: sdp... done.
IIB Database file has been successfully backed up to the backup folder.
Startup time: 70.9s (import torch: 7.6s, import gradio: 1.4s, setup paths: 3.5s, initialize shared: 0.4s, other imports: 2.3s, list SD models: 0.7s, load scripts: 44.2s, create ui: 8.2s, gradio launch: 0.6s, add APIs: 1.6s).
Model loaded in 10.9s (load weights from disk: 0.3s, create model: 1.9s, apply weights to model: 6.1s, apply half(): 1.0s, apply dtype to VAE: 0.1s, move model to device: 0.8s, hijack: 0.2s, calculate empty prompt: 0.3s).
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/gradio/routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1435, in process_api
    result = await self.call_function(
  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1107, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "/workspace/sd/stable-diffusion-webui/extensions/sd-civitai-browser-plus/scripts/civitai_api.py", line 368, in initial_model_page
    gl.json_data = request_civit_api(api_url)
  File "/workspace/sd/stable-diffusion-webui/extensions/sd-civitai-browser-plus/scripts/civitai_api.py", line 1188, in request_civit_api
    headers = get_headers()
  File "/workspace/sd/stable-diffusion-webui/extensions/sd-civitai-browser-plus/scripts/civitai_api.py", line 1171, in get_headers
    user_agent = UserAgent().chrome
NameError: name 'UserAgent' is not defined
*** API error: POST: http://100.65.18.103/infinite_image_browsing/open_folder {'error': 'FileNotFoundError', 'detail': '', 'body': '', 'errors': "[Errno 2] No such file or directory: 'xdg-open'"}
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 94, in receive
        return self.receive_nowait()
      File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 89, in receive_nowait
        raise WouldBlock
    anyio.WouldBlock

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 77, in call_next
        message = await recv_stream.receive()
      File "/usr/local/lib/python3.10/dist-packages/anyio/streams/memory.py", line 114, in receive
        raise EndOfStream
    anyio.EndOfStream

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/workspace/sd/stable-diffusion-webui/modules/api/api.py", line 186, in exception_handling
        return await call_next(request)
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 80, in call_next
        raise app_exc
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 69, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 106, in __call__
        response = await self.dispatch_func(request, call_next)
      File "/workspace/sd/stable-diffusion-webui/modules/api/api.py", line 150, in log_and_time
        res: Response = await call_next(req)
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 80, in call_next
        raise app_exc
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/base.py", line 69, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 92, in __call__
        await self.simple_response(scope, receive, send, request_headers=headers)
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 147, in simple_response
        await self.app(scope, receive, send)
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/gzip.py", line 24, in __call__
        await responder(scope, receive, send)
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/gzip.py", line 43, in __call__
        await self.app(scope, receive, self.send_with_gzip)
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 79, in __call__
        raise exc
      File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 68, in __call__
        await self.app(scope, receive, sender)
      File "/usr/local/lib/python3.10/dist-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
        raise e
      File "/usr/local/lib/python3.10/dist-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
        await self.app(scope, receive, send)
      File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 706, in __call__
        await route.handle(scope, receive, send)
      File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 276, in handle
        await self.app(scope, receive, send)
      File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 66, in app
        response = await func(request)
      File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 235, in app
        raw_response = await run_endpoint_function(
      File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 163, in run_endpoint_function
        return await run_in_threadpool(dependant.call, **values)
      File "/usr/local/lib/python3.10/dist-packages/starlette/concurrency.py", line 41, in run_in_threadpool
        return await anyio.to_thread.run_sync(func, *args)
      File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 31, in run_sync
        return await get_asynclib().run_sync_in_worker_thread(
      File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
        return await future
      File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 867, in run
        result = context.run(func, *args)
      File "/workspace/sd/stable-diffusion-webui/extensions/sd-webui-infinite-image-browsing/scripts/iib/api.py", line 644, in open_folder_using_explore
        open_folder(*os.path.split(req.path))
      File "/workspace/sd/stable-diffusion-webui/extensions/sd-webui-infinite-image-browsing/scripts/iib/tool.py", line 582, in open_folder
        subprocess.run(["xdg-open", folder])
      File "/usr/lib/python3.10/subprocess.py", line 503, in run
        with Popen(*popenargs, **kwargs) as process:
      File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'xdg-open'

Additional information

No response

BlafKing commented 3 months ago

Hi there, thanks for reporting apologies for the delayed response.

I can see that you're missing some required python packages for the extension, the extension should still work without these, but it might be worth a shot to try installing them.

I've personally never used Runpod before, so I'm not sure how you would go about installing python packages with pip, but you should get these 2 packages as printed in the console:

CivitAI Browser+: Python module 'fake_useragent' has not been imported correctly, please try to restart or install it manually.
CivitAI Browser+: Python module 'ZipUnicode' has not been imported correctly, please try to restart or install it manually.

You should be able to install them by doing

pip install fake-useragent
pip install ZipUnicode

I'll do some more checking/testing if you can verify that this solution did or did not work :)

BlafKing commented 2 months ago

I'll close this report as there hasn't been a reply in a while, I'll be more than glad to open it back up again if you can report if installing those packages fixed the issue! :)