Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline
|
| 3 |
from diffusers import StableDiffusionInpaintPipeline, AutoencoderKL
|
| 4 |
from diffusers import DPMSolverMultistepScheduler, PNDMScheduler
|
| 5 |
-
|
| 6 |
import torch
|
| 7 |
from PIL import Image, ImageDraw
|
| 8 |
import time
|
|
@@ -1014,40 +1014,22 @@ def main_ui():
|
|
| 1014 |
concurrency_limit=1
|
| 1015 |
)
|
| 1016 |
|
| 1017 |
-
|
| 1018 |
-
def
|
| 1019 |
-
|
| 1020 |
-
|
| 1021 |
-
on_tab_change(tab_name)
|
| 1022 |
-
return tab_name
|
| 1023 |
|
| 1024 |
-
#
|
| 1025 |
-
|
| 1026 |
-
|
| 1027 |
-
outputs=current_tab
|
| 1028 |
-
)
|
| 1029 |
|
| 1030 |
-
#
|
| 1031 |
-
txt_tab.select(
|
| 1032 |
-
fn=lambda: update_current_tab(0),
|
| 1033 |
-
outputs=current_tab,
|
| 1034 |
-
queue=False
|
| 1035 |
-
)
|
| 1036 |
-
|
| 1037 |
-
img_tab.select(
|
| 1038 |
-
fn=lambda: update_current_tab(1),
|
| 1039 |
-
outputs=current_tab,
|
| 1040 |
-
queue=False
|
| 1041 |
-
)
|
| 1042 |
|
| 1043 |
# Queue mit Load-Balancing konfigurieren
|
| 1044 |
-
demo.queue(
|
| 1045 |
-
max_size=2, # Reduziere max_size für besseres Load-Balancing
|
| 1046 |
-
default_concurrency_limit=1,
|
| 1047 |
-
api_open=False
|
| 1048 |
-
)
|
| 1049 |
|
| 1050 |
-
return demo
|
|
|
|
| 1051 |
|
| 1052 |
if __name__ == "__main__":
|
| 1053 |
import atexit
|
|
|
|
| 2 |
from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline
|
| 3 |
from diffusers import StableDiffusionInpaintPipeline, AutoencoderKL
|
| 4 |
from diffusers import DPMSolverMultistepScheduler, PNDMScheduler
|
| 5 |
+
from controlnet_module import controlnet_processor
|
| 6 |
import torch
|
| 7 |
from PIL import Image, ImageDraw
|
| 8 |
import time
|
|
|
|
| 1014 |
concurrency_limit=1
|
| 1015 |
)
|
| 1016 |
|
| 1017 |
+
|
| 1018 |
+
def handle_tab_switch():
|
| 1019 |
+
"""Leere Funktion nur um Tab-Wechsel zu registrieren"""
|
| 1020 |
+
return
|
|
|
|
|
|
|
| 1021 |
|
| 1022 |
+
# Füge diese Event-Handler hinzu:
|
| 1023 |
+
txt_tab.select(fn=handle_tab_switch, queue=False)
|
| 1024 |
+
img_tab.select(fn=handle_tab_switch, queue=False)
|
|
|
|
|
|
|
| 1025 |
|
| 1026 |
+
# === ENDE TAB WECHSEL OPTIMIERUNG ===
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1027 |
|
| 1028 |
# Queue mit Load-Balancing konfigurieren
|
| 1029 |
+
demo.queue(max_size=2, default_concurrency_limit=1, api_open=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1030 |
|
| 1031 |
+
return demo
|
| 1032 |
+
|
| 1033 |
|
| 1034 |
if __name__ == "__main__":
|
| 1035 |
import atexit
|