Astridkraft commited on
Commit
f6176b5
·
verified ·
1 Parent(s): 352bf8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -30
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
- #from controlnet_module import controlnet_processor
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
- # Tab-Wechsel Event-Handler
1018
- def update_current_tab(selected_tab):
1019
- # Konvertiere Tab-Objekt zu Namen
1020
- tab_name = "Text zu Bild" if selected_tab == 0 else "Bild zu Bild"
1021
- on_tab_change(tab_name)
1022
- return tab_name
1023
 
1024
- # Event für Tab-Wechsel
1025
- demo.load(
1026
- fn=lambda: "Text zu Bild",
1027
- outputs=current_tab
1028
- )
1029
 
1030
- # Tab-Wechsel verfolgen
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