Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,7 +58,7 @@ text_generator, image_generator, client_3d, tts_processor, tts_model, vocoder, s
|
|
| 58 |
LLM_LOADED, IMAGE_MODEL_LOADED, CLIENT_3D_LOADED, TTS_LOADED = (False,) * 4
|
| 59 |
|
| 60 |
# --- Funkcje 艂adowania modeli ---
|
| 61 |
-
def
|
| 62 |
global text_generator, image_generator, client_3d, tts_processor, tts_model, vocoder, speaker_embeddings
|
| 63 |
global LLM_LOADED, IMAGE_MODEL_LOADED, CLIENT_3D_LOADED, TTS_LOADED
|
| 64 |
|
|
@@ -82,6 +82,9 @@ def load_models():
|
|
| 82 |
TTS_LOADED = True
|
| 83 |
print("Modele TTS za艂adowane.")
|
| 84 |
except Exception as e: print(f"B艂膮d 艂adowania modeli TTS: {e}")
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
# --- Funkcje pomocnicze i g艂贸wne ---
|
| 87 |
def list_saved_projects():
|
|
@@ -131,7 +134,6 @@ def generate_course_structure_and_images(topic, progress=gr.Progress(track_tqdm=
|
|
| 131 |
|
| 132 |
return generated_images, gr.State(generated_images), gr.update(visible=True), gr.update(visible=True), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True), *updates
|
| 133 |
|
| 134 |
-
# ... (pozosta艂e funkcje: load_project, update_preview, move_step, etc. bez zmian) ...
|
| 135 |
def load_project(project_name):
|
| 136 |
if not project_name:
|
| 137 |
gr.Warning("Wybierz projekt do wczytania.")
|
|
@@ -296,8 +298,8 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="sky", secondary_hue="blue"), ti
|
|
| 296 |
gr.Markdown("<h2 class='section-title'>鈿欙笍 Panel Sterowania</h2>")
|
| 297 |
with gr.Group():
|
| 298 |
gr.Markdown("### 1. Wygeneruj lub Wczytaj Projekt")
|
| 299 |
-
topic_input = gr.Textbox(label="Wpisz temat nowego kursu", placeholder="np. Jak zbudowa膰 domek dla je偶y?", lines=3)
|
| 300 |
-
generate_button = gr.Button("馃殌 Wygeneruj Nowy Kurs!", variant="primary")
|
| 301 |
with gr.Accordion("馃摎 Biblioteka Projekt贸w", open=True):
|
| 302 |
saved_projects_dropdown = gr.Dropdown(label="Wybierz zapisany projekt", choices=list_saved_projects(), interactive=True)
|
| 303 |
load_project_button = gr.Button("馃搨 Wczytaj Projekt")
|
|
@@ -351,6 +353,13 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="sky", secondary_hue="blue"), ti
|
|
| 351 |
image_gallery, images_state, editor_group, preview_group,
|
| 352 |
pdf_button, save_button, video_button
|
| 353 |
] + editor_text_fields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
|
| 355 |
generate_button.click(
|
| 356 |
fn=generate_course_structure_and_images,
|
|
@@ -393,8 +402,5 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="sky", secondary_hue="blue"), ti
|
|
| 393 |
inputs=[images_state] + editor_text_fields,
|
| 394 |
outputs=[video_output]
|
| 395 |
)
|
| 396 |
-
|
| 397 |
-
# Uruchomienie aplikacji po za艂adowaniu modeli
|
| 398 |
demo.queue().launch(show_api=False)
|
| 399 |
-
# Wywo艂anie funkcji 艂aduj膮cej modele po zdefiniowaniu interfejsu
|
| 400 |
-
load_models()
|
|
|
|
| 58 |
LLM_LOADED, IMAGE_MODEL_LOADED, CLIENT_3D_LOADED, TTS_LOADED = (False,) * 4
|
| 59 |
|
| 60 |
# --- Funkcje 艂adowania modeli ---
|
| 61 |
+
def load_all_models():
|
| 62 |
global text_generator, image_generator, client_3d, tts_processor, tts_model, vocoder, speaker_embeddings
|
| 63 |
global LLM_LOADED, IMAGE_MODEL_LOADED, CLIENT_3D_LOADED, TTS_LOADED
|
| 64 |
|
|
|
|
| 82 |
TTS_LOADED = True
|
| 83 |
print("Modele TTS za艂adowane.")
|
| 84 |
except Exception as e: print(f"B艂膮d 艂adowania modeli TTS: {e}")
|
| 85 |
+
|
| 86 |
+
# Zwracamy informacj臋 do UI, 偶e modele s膮 gotowe
|
| 87 |
+
return gr.update(interactive=True)
|
| 88 |
|
| 89 |
# --- Funkcje pomocnicze i g艂贸wne ---
|
| 90 |
def list_saved_projects():
|
|
|
|
| 134 |
|
| 135 |
return generated_images, gr.State(generated_images), gr.update(visible=True), gr.update(visible=True), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True), *updates
|
| 136 |
|
|
|
|
| 137 |
def load_project(project_name):
|
| 138 |
if not project_name:
|
| 139 |
gr.Warning("Wybierz projekt do wczytania.")
|
|
|
|
| 298 |
gr.Markdown("<h2 class='section-title'>鈿欙笍 Panel Sterowania</h2>")
|
| 299 |
with gr.Group():
|
| 300 |
gr.Markdown("### 1. Wygeneruj lub Wczytaj Projekt")
|
| 301 |
+
topic_input = gr.Textbox(label="Wpisz temat nowego kursu", placeholder="np. Jak zbudowa膰 domek dla je偶y?", lines=3, interactive=False)
|
| 302 |
+
generate_button = gr.Button("馃殌 Wygeneruj Nowy Kurs!", variant="primary", interactive=False)
|
| 303 |
with gr.Accordion("馃摎 Biblioteka Projekt贸w", open=True):
|
| 304 |
saved_projects_dropdown = gr.Dropdown(label="Wybierz zapisany projekt", choices=list_saved_projects(), interactive=True)
|
| 305 |
load_project_button = gr.Button("馃搨 Wczytaj Projekt")
|
|
|
|
| 353 |
image_gallery, images_state, editor_group, preview_group,
|
| 354 |
pdf_button, save_button, video_button
|
| 355 |
] + editor_text_fields
|
| 356 |
+
|
| 357 |
+
# POPRAWKA: U偶ywamy zdarzenia `load` do uruchomienia 艂adowania modeli
|
| 358 |
+
demo.load(
|
| 359 |
+
fn=load_all_models,
|
| 360 |
+
inputs=None,
|
| 361 |
+
outputs=[generate_button] # Aktywujemy przycisk po za艂adowaniu
|
| 362 |
+
)
|
| 363 |
|
| 364 |
generate_button.click(
|
| 365 |
fn=generate_course_structure_and_images,
|
|
|
|
| 402 |
inputs=[images_state] + editor_text_fields,
|
| 403 |
outputs=[video_output]
|
| 404 |
)
|
| 405 |
+
|
|
|
|
| 406 |
demo.queue().launch(show_api=False)
|
|
|
|
|
|