Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -2486,13 +2486,17 @@ def apply_example(idx: str):
|
|
| 2486 |
gr.update(value=None), gr.update(visible=False)
|
| 2487 |
)
|
| 2488 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2489 |
# --- توابع کنترل کننده (بدون وابستگی محلی) ---
|
| 2490 |
|
| 2491 |
def ui_lock_and_enhance(first_frame, prompt, mode, enhance_toggle):
|
| 2492 |
"""
|
| 2493 |
مرحله ۱: قفل کردن UI و بررسی اینکه آیا پرامپت نیاز به بهینهسازی دارد یا خیر
|
| 2494 |
"""
|
| 2495 |
-
if enhance_toggle ==
|
| 2496 |
yield (
|
| 2497 |
gr.Button(value="⏳ در حال بهینه سازی پرامپت (CPU)...", interactive=False),
|
| 2498 |
gr.update(),
|
|
@@ -2690,7 +2694,7 @@ with gr.Blocks(title="LTX-2 Video Distilled 🎥🔈") as demo:
|
|
| 2690 |
camera_ui = CameraDropdown(choices=[name for name, _ in VISIBLE_RUNTIME_LORA_CHOICES], value="No LoRA", title="افکت دوربین (LoRA)", elem_id="camera_ui")
|
| 2691 |
camera_lora = gr.Dropdown(label="Camera Control LoRA", choices=[name for name, _ in VISIBLE_RUNTIME_LORA_CHOICES], value="No LoRA", visible=False)
|
| 2692 |
|
| 2693 |
-
# استایلهای
|
| 2694 |
gr.HTML("""
|
| 2695 |
<style>
|
| 2696 |
#enhance-toggle-col {
|
|
@@ -2698,7 +2702,7 @@ with gr.Blocks(title="LTX-2 Video Distilled 🎥🔈") as demo:
|
|
| 2698 |
flex-direction: column !important;
|
| 2699 |
align-items: center !important;
|
| 2700 |
justify-content: center !important;
|
| 2701 |
-
margin:
|
| 2702 |
width: 100% !important;
|
| 2703 |
text-align: center !important;
|
| 2704 |
}
|
|
@@ -2711,11 +2715,16 @@ with gr.Blocks(title="LTX-2 Video Distilled 🎥🔈") as demo:
|
|
| 2711 |
#enhance_toggle .ra-wrap {
|
| 2712 |
margin: 0 auto !important;
|
| 2713 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2714 |
.enhance-helper-text {
|
| 2715 |
-
font-size:
|
| 2716 |
color: rgba(255, 255, 255, 0.55);
|
| 2717 |
text-align: center;
|
| 2718 |
-
margin-top:
|
| 2719 |
margin-left: auto;
|
| 2720 |
margin-right: auto;
|
| 2721 |
max-width: 90%;
|
|
@@ -2724,11 +2733,11 @@ with gr.Blocks(title="LTX-2 Video Distilled 🎥🔈") as demo:
|
|
| 2724 |
</style>
|
| 2725 |
""")
|
| 2726 |
|
| 2727 |
-
# افزودن سوییچ پرامپت
|
| 2728 |
with gr.Column(elem_id="enhance-toggle-col"):
|
| 2729 |
enhance_toggle = RadioAnimated(
|
| 2730 |
-
choices=[
|
| 2731 |
-
value=
|
| 2732 |
elem_id="enhance_toggle"
|
| 2733 |
)
|
| 2734 |
gr.HTML('<div class="enhance-helper-text">بهترین حالت برای درک بهتر دستور و ساخت ویدیو بر اساس پرامپت شما، بهتره حالت روی «بهینه شود» باشه.</div>')
|
|
|
|
| 2486 |
gr.update(value=None), gr.update(visible=False)
|
| 2487 |
)
|
| 2488 |
|
| 2489 |
+
# تعریف متغیرهای متنی برای دکمهها با استایلهای داخلی (کوچک کردن کلمه پیشفرض)
|
| 2490 |
+
ENHANCE_YES_TEXT = "دستور بهینه شود <span style='font-size: 0.75em; font-weight: normal; opacity: 0.75;'>(پیشفرض)</span> ✨"
|
| 2491 |
+
ENHANCE_NO_TEXT = "دستور بهینه نشود ✋"
|
| 2492 |
+
|
| 2493 |
# --- توابع کنترل کننده (بدون وابستگی محلی) ---
|
| 2494 |
|
| 2495 |
def ui_lock_and_enhance(first_frame, prompt, mode, enhance_toggle):
|
| 2496 |
"""
|
| 2497 |
مرحله ۱: قفل کردن UI و بررسی اینکه آیا پرامپت نیاز به بهینهسازی دارد یا خیر
|
| 2498 |
"""
|
| 2499 |
+
if enhance_toggle == ENHANCE_YES_TEXT:
|
| 2500 |
yield (
|
| 2501 |
gr.Button(value="⏳ در حال بهینه سازی پرامپت (CPU)...", interactive=False),
|
| 2502 |
gr.update(),
|
|
|
|
| 2694 |
camera_ui = CameraDropdown(choices=[name for name, _ in VISIBLE_RUNTIME_LORA_CHOICES], value="No LoRA", title="افکت دوربین (LoRA)", elem_id="camera_ui")
|
| 2695 |
camera_lora = gr.Dropdown(label="Camera Control LoRA", choices=[name for name, _ in VISIBLE_RUNTIME_LORA_CHOICES], value="No LoRA", visible=False)
|
| 2696 |
|
| 2697 |
+
# استایلهای بهینهشده برای کوچکتر کردن دکمهها و قرار دادن در مرکز صفحه
|
| 2698 |
gr.HTML("""
|
| 2699 |
<style>
|
| 2700 |
#enhance-toggle-col {
|
|
|
|
| 2702 |
flex-direction: column !important;
|
| 2703 |
align-items: center !important;
|
| 2704 |
justify-content: center !important;
|
| 2705 |
+
margin: 15px auto !important;
|
| 2706 |
width: 100% !important;
|
| 2707 |
text-align: center !important;
|
| 2708 |
}
|
|
|
|
| 2715 |
#enhance_toggle .ra-wrap {
|
| 2716 |
margin: 0 auto !important;
|
| 2717 |
}
|
| 2718 |
+
/* استایل برای کوچکتر کردن سایز دکمههای RadioAnimated به طور خاص */
|
| 2719 |
+
#enhance_toggle .ra-label {
|
| 2720 |
+
padding: 7px 12px !important;
|
| 2721 |
+
font-size: 12.5px !important;
|
| 2722 |
+
}
|
| 2723 |
.enhance-helper-text {
|
| 2724 |
+
font-size: 11px; /* متن راهنما نیز کمی کوچکتر شد */
|
| 2725 |
color: rgba(255, 255, 255, 0.55);
|
| 2726 |
text-align: center;
|
| 2727 |
+
margin-top: 8px;
|
| 2728 |
margin-left: auto;
|
| 2729 |
margin-right: auto;
|
| 2730 |
max-width: 90%;
|
|
|
|
| 2733 |
</style>
|
| 2734 |
""")
|
| 2735 |
|
| 2736 |
+
# افزودن سوییچ پرامپت با متون سفارشی
|
| 2737 |
with gr.Column(elem_id="enhance-toggle-col"):
|
| 2738 |
enhance_toggle = RadioAnimated(
|
| 2739 |
+
choices=[ENHANCE_YES_TEXT, ENHANCE_NO_TEXT],
|
| 2740 |
+
value=ENHANCE_YES_TEXT,
|
| 2741 |
elem_id="enhance_toggle"
|
| 2742 |
)
|
| 2743 |
gr.HTML('<div class="enhance-helper-text">بهترین حالت برای درک بهتر دستور و ساخت ویدیو بر اساس پرامپت شما، بهتره حالت روی «بهینه شود» باشه.</div>')
|