Commit
•
477657c
1
Parent(s):
6a75af4
Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,7 @@ from openai import OpenAI
|
|
24 |
# Load Hugging Face token if needed
|
25 |
hf_token = os.getenv("HF_TOKEN")
|
26 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
|
|
27 |
|
28 |
system_prompt_t2v_path = "assets/system_prompt_t2v.txt"
|
29 |
system_prompt_i2v_path = "assets/system_prompt_i2v.txt"
|
@@ -204,6 +205,7 @@ pipeline = XoraVideoPipeline(
|
|
204 |
|
205 |
|
206 |
def generate_video_from_text(
|
|
|
207 |
prompt="",
|
208 |
enhance_prompt_toggle=False,
|
209 |
negative_prompt="",
|
@@ -216,6 +218,10 @@ def generate_video_from_text(
|
|
216 |
num_frames=121,
|
217 |
progress=gr.Progress(),
|
218 |
):
|
|
|
|
|
|
|
|
|
219 |
if len(prompt.strip()) < 50:
|
220 |
raise gr.Error(
|
221 |
"Prompt must be at least 50 characters long. Please provide more details for the best results.",
|
@@ -422,64 +428,13 @@ def create_advanced_options():
|
|
422 |
|
423 |
# Define the Gradio interface with tabs
|
424 |
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
<
|
429 |
-
|
430 |
-
</div>
|
431 |
-
"""
|
432 |
-
)
|
433 |
-
with gr.Row(elem_id="title-row"):
|
434 |
-
gr.HTML( # add technical report link
|
435 |
-
"""
|
436 |
-
<div style="display:flex;column-gap:4px;">
|
437 |
-
<a href="https://github.com/Lightricks/LTX-Video">
|
438 |
-
<img src='https://img.shields.io/badge/GitHub-Repo-blue'>
|
439 |
-
</a>
|
440 |
-
<a href="https://github.com/Lightricks/ComfyUI-LTXVideo">
|
441 |
-
<img src='https://img.shields.io/badge/GitHub-ComfyUI-blue'>
|
442 |
-
</a>
|
443 |
-
<a href="http://www.lightricks.com/ltxv">
|
444 |
-
<img src="https://img.shields.io/badge/Project-Page-green" alt="Follow me on HF">
|
445 |
-
</a>
|
446 |
-
<a href="https://huggingface.co/spaces/Lightricks/LTX-Video-Playground?duplicate=true">
|
447 |
-
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-sm.svg" alt="Duplicate this Space">
|
448 |
-
</a>
|
449 |
-
<a href="https://huggingface.co/Lightricks">
|
450 |
-
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/follow-me-on-HF-sm-dark.svg" alt="Follow me on HF">
|
451 |
-
</a>
|
452 |
</div>
|
453 |
-
"""
|
454 |
-
)
|
455 |
-
with gr.Accordion(
|
456 |
-
" 📖 Tips for Best Results", open=False, elem_id="instructions-accordion"
|
457 |
-
):
|
458 |
-
gr.Markdown(
|
459 |
-
"""
|
460 |
-
📝 Prompt Engineering
|
461 |
-
|
462 |
-
When writing prompts, focus on detailed, chronological descriptions of actions and scenes. Include specific movements, appearances, camera angles, and environmental details - all in a single flowing paragraph. Start directly with the action, and keep descriptions literal and precise. Think like a cinematographer describing a shot list. Keep within 200 words.
|
463 |
-
For best results, build your prompts using this structure:
|
464 |
-
|
465 |
-
- Start with main action in a single sentence
|
466 |
-
- Add specific details about movements and gestures
|
467 |
-
- Describe character/object appearances precisely
|
468 |
-
- Include background and environment details
|
469 |
-
- Specify camera angles and movements
|
470 |
-
- Describe lighting and colors
|
471 |
-
- Note any changes or sudden events
|
472 |
-
|
473 |
-
See examples for more inspiration.
|
474 |
-
|
475 |
-
🎮 Parameter Guide
|
476 |
-
|
477 |
-
- Resolution Preset: Higher resolutions for detailed scenes, lower for faster generation and simpler scenes
|
478 |
-
- Seed: Save seed values to recreate specific styles or compositions you like
|
479 |
-
- Guidance Scale: 3-3.5 are the recommended values
|
480 |
-
- Inference Steps: More steps (40+) for quality, fewer steps (20-30) for speed
|
481 |
-
"""
|
482 |
-
)
|
483 |
|
484 |
with gr.Tabs():
|
485 |
# Text to Video Tab
|
@@ -556,6 +511,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
|
556 |
with gr.TabItem("Image to Video"):
|
557 |
with gr.Row():
|
558 |
with gr.Column():
|
|
|
559 |
img2vid_image = gr.Image(
|
560 |
type="filepath",
|
561 |
label="Step 1: Upload Input Image",
|
@@ -640,6 +596,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
|
640 |
txt2vid_generate.click(
|
641 |
fn=generate_video_from_text,
|
642 |
inputs=[
|
|
|
643 |
txt2vid_prompt,
|
644 |
txt2vid_enhance_toggle,
|
645 |
txt2vid_negative_prompt,
|
@@ -673,6 +630,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
|
673 |
)
|
674 |
|
675 |
if __name__ == "__main__":
|
676 |
-
iface.queue(max_size=
|
677 |
-
share=True, show_api=
|
678 |
)
|
|
|
24 |
# Load Hugging Face token if needed
|
25 |
hf_token = os.getenv("HF_TOKEN")
|
26 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
27 |
+
SECRET_TOKEN = os.getenv('SECRET_TOKEN', 'default_secret')
|
28 |
|
29 |
system_prompt_t2v_path = "assets/system_prompt_t2v.txt"
|
30 |
system_prompt_i2v_path = "assets/system_prompt_i2v.txt"
|
|
|
205 |
|
206 |
|
207 |
def generate_video_from_text(
|
208 |
+
secret_token="",
|
209 |
prompt="",
|
210 |
enhance_prompt_toggle=False,
|
211 |
negative_prompt="",
|
|
|
218 |
num_frames=121,
|
219 |
progress=gr.Progress(),
|
220 |
):
|
221 |
+
if secret_token != SECRET_TOKEN:
|
222 |
+
raise gr.Error(
|
223 |
+
f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
|
224 |
+
|
225 |
if len(prompt.strip()) < 50:
|
226 |
raise gr.Error(
|
227 |
"Prompt must be at least 50 characters long. Please provide more details for the best results.",
|
|
|
428 |
|
429 |
# Define the Gradio interface with tabs
|
430 |
with gr.Blocks(theme=gr.themes.Soft()) as iface:
|
431 |
+
gr.HTML("""
|
432 |
+
<div style="z-index: 100; position: fixed; top: 0px; right: 0px; left: 0px; bottom: 0px; width: 100%; height: 100%; background: white; display: flex; align-items: center; justify-content: center; color: black;">
|
433 |
+
<div style="text-align: center; color: black;">
|
434 |
+
<p style="color: black;">This space is a headless component of the cloud rendering engine used by AiTube.</p>
|
435 |
+
<p style="color: black;">It is not available for public use, but you can use the <a href="https://huggingface.co/spaces/Lightricks/LTX-Video-Playground" target="_blank">original space</a>.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
</div>
|
437 |
+
</div>""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
|
439 |
with gr.Tabs():
|
440 |
# Text to Video Tab
|
|
|
511 |
with gr.TabItem("Image to Video"):
|
512 |
with gr.Row():
|
513 |
with gr.Column():
|
514 |
+
secret_token = gr.Textbox()
|
515 |
img2vid_image = gr.Image(
|
516 |
type="filepath",
|
517 |
label="Step 1: Upload Input Image",
|
|
|
596 |
txt2vid_generate.click(
|
597 |
fn=generate_video_from_text,
|
598 |
inputs=[
|
599 |
+
secret_token,
|
600 |
txt2vid_prompt,
|
601 |
txt2vid_enhance_toggle,
|
602 |
txt2vid_negative_prompt,
|
|
|
630 |
)
|
631 |
|
632 |
if __name__ == "__main__":
|
633 |
+
iface.queue(max_size=32, default_concurrency_limit=1, api_open=False).launch(
|
634 |
+
share=True, show_api=True
|
635 |
)
|