Bing-su / adetailer

Auto detecting, masking and inpainting with detection model.
GNU Affero General Public License v3.0
4.09k stars 316 forks source link

[Bug]: Unknown Page Redirect #691

Closed player99963 closed 1 day ago

player99963 commented 3 weeks ago

Describe the bug

When selecting the AfterDetailer Model, the web UI often directly navigates to the model's name URL, for example: http://yolov8s-seg.pt/.

Steps to reproduce

I installed the web UI using stable matrix, and the web UI version is 1.10.0. This issue can occur when using any AfterDetailer Model in either t2i or i2i. A model might work fine this time, but the next time I start and use it, it may cause a page redirect.

Screenshots

image

Console logs, from start to end.

venv "D:\Data\Packages\Stable Diffusion WebUI\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.10.0
Commit hash: c19d04436496ab29ddca4758a792831ae41b31de
Launching Web UI with arguments: --theme dark --api
No module 'xformers'. Proceeding without it.
[-] ADetailer initialized. version: 24.8.0, num models: 31
Loading weights [e030bf78dd] from D:\Data\Packages\Stable Diffusion WebUI\models\Stable-diffusion\Pony Diffusion V6\stuffyMixXL_v10.safetensors
Creating model from config: D:\Data\Packages\Stable Diffusion WebUI\repositories\generative-models\configs\inference\sd_xl_base.yaml
Running on local URL:  http://127.0.0.1:7860
D:\Data\Packages\Stable Diffusion WebUI\venv\lib\site-packages\huggingface_hub\file_download.py:1150: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
  warnings.warn(

To create a public link, set `share=True` in `launch()`.
Startup time: 10.6s (prepare environment: 2.4s, import torch: 2.6s, import gradio: 0.4s, setup paths: 0.6s, initialize shared: 0.2s, other imports: 0.4s, list SD models: 0.1s, load scripts: 0.8s, create ui: 0.4s, gradio launch: 2.4s, add APIs: 0.3s).
Loading VAE weights specified in settings: D:\Data\Packages\Stable Diffusion WebUI\models\VAE\fixFP16ErrorsSDXLLowerMemoryUse_v10.safetensors
Applying attention optimization: sdp-no-mem... done.
Model loaded in 4.4s (load weights from disk: 0.2s, create model: 1.3s, apply weights to model: 2.4s, load VAE: 0.2s, calculate empty prompt: 0.1s).

List of installed extensions

image

dosubot[bot] commented 3 weeks ago

Hey @player99963, I'm here to help you with any bugs, questions, or contributions you have regarding the repository. Let me know how I can assist you!

To fix the issue of the web UI redirecting to an unknown page when using the AfterDetailer Model in version 1.10.0, you need to ensure that the on_after_component function correctly identifies and sets the txt2img_submit_button and img2img_submit_button components. Here is the relevant code snippet:

def on_after_component(component, **_kwargs):
    global txt2img_submit_button, img2img_submit_button
    if getattr(component, "elem_id", None) == "txt2img_generate":
        txt2img_submit_button = component
        return

    if getattr(component, "elem_id", None) == "img2img_generate":
        img2img_submit_button = component

Make sure that the elem_id values for the components are correctly set to "txt2img_generate" and "img2img_generate". If these IDs are incorrect or not set, the buttons will not be properly identified, leading to potential issues with the UI redirection [1].

To continue talking to Dosu, mention @dosu.

player99963 commented 3 weeks ago

@dosu Programming is not my specialty, so can you tell me exactly which file in which location to modify to solve this problem?

dosubot[bot] commented 3 weeks ago

To solve the issue of the web UI redirecting to an unknown page when using the AfterDetailer Model, you need to modify the on_after_component function in the scripts/!adetailer.py file.

Here is the relevant code snippet:

def on_after_component(component, **_kwargs):
    global txt2img_submit_button, img2img_submit_button
    if getattr(component, "elem_id", None) == "txt2img_generate":
        txt2img_submit_button = component
        return

    if getattr(component, "elem_id", None) == "img2img_generate":
        img2img_submit_button = component

Ensure that the elem_id values for the components are correctly set to "txt2img_generate" and "img2img_generate". This file is located in the scripts directory of the adetailer repository [1].

To continue talking to Dosu, mention @dosu.

player99963 commented 3 weeks ago

@dosu I checked and it doesn't look like there's anything wrong with it.

def on_after_component(component, **_kwargs): global txt2img_submit_button, img2img_submit_button if getattr(component, "elem_id", None) == "txt2img_generate": txt2img_submit_button = component return

if getattr(component, "elem_id", None) == "img2img_generate":
    img2img_submit_button = component
dosubot[bot] commented 3 weeks ago

If the on_after_component function looks correct, the issue might be related to other parts of the code or configuration. Here are a few things to check:

  1. Dependencies and External Libraries: Ensure that the script_callbacks module and its associated mechanisms are functioning correctly, as they can influence the behavior of the on_after_component function and the web UI redirection [1].

  2. Other Event Handlers or Callback Functions: There are other event handlers or callback functions in the scripts/!adetailer.py file that might interact with the web UI components or cause redirection issues. Specifically, check the following functions:

    • on_ui_settings
    • on_before_ui
    • add_api_endpoints

    These functions are registered with the following lines of code:

    script_callbacks.on_ui_settings(on_ui_settings)
    script_callbacks.on_after_component(on_after_component)
    script_callbacks.on_app_started(add_api_endpoints)
    script_callbacks.on_before_ui(on_before_ui)

    Ensure these functions are not causing any unintended behavior [1].

  3. Configuration Files or Settings: Check the configuration settings added by the on_ui_settings function, as they might influence the behavior of the web UI. These settings include options like ad_max_models, ad_extra_models_dir, and others [1][2].

  4. Model Initialization and Loading: Verify that the models are being loaded and initialized correctly. The get_models function is responsible for loading the models, and the get_ad_model method retrieves a model based on its name. Ensure there is no code inadvertently setting a URL based on the model's name [1].

  5. Explicit URL Modifications: Check if there is any code explicitly setting or modifying URLs for the web UI components. The add_api_endpoints function adds several API endpoints to the FastAPI app, but ensure there are no unintended URL modifications [1].

By checking these areas, you might be able to identify the root cause of the web UI redirection issue.

To continue talking to Dosu, mention @dosu.