File size: 2,218 Bytes
4862c84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""
Demo script showing different ways to use the LMM-Vibes Gradio visualization.

This demonstrates the Python API for launching the Gradio app.
"""

import argparse
from pathlib import Path
from lmmvibes.vis_gradio import launch_app, create_app


def demo_basic_launch():
    """Demo: Basic launch without pre-loading data."""
    print("πŸš€ Demo: Basic launch - data can be loaded through the UI")
    launch_app()


def demo_preload_data(results_dir: str):
    """Demo: Launch with pre-loaded data."""
    print(f"πŸš€ Demo: Launch with pre-loaded data from {results_dir}")
    launch_app(results_dir=results_dir)


def demo_custom_settings(results_dir: str = None):
    """Demo: Launch with custom settings."""
    print("πŸš€ Demo: Launch with custom settings")
    launch_app(
        results_dir=results_dir,
        share=True,  # Create public shareable link
        server_name="0.0.0.0",  # Allow access from other machines
        server_port=8080,  # Custom port
    )


def demo_programmatic_access():
    """Demo: Create app object for programmatic access."""
    print("πŸš€ Demo: Programmatic app creation")
    
    # Create the app object without launching
    app = create_app()
    
    # You could modify the app here if needed
    # app.title = "My Custom Title"
    
    # Launch when ready
    print("Launching app...")
    app.launch(share=False, server_port=7861)


def main():
    parser = argparse.ArgumentParser(description="LMM-Vibes Gradio Visualization Demo")
    parser.add_argument("--results_dir", help="Path to results directory for demos")
    parser.add_argument("--demo", choices=[
        "basic", "preload", "custom", "programmatic"
    ], default="basic", help="Which demo to run")
    
    args = parser.parse_args()
    
    if args.demo == "basic":
        demo_basic_launch()
    elif args.demo == "preload":
        if not args.results_dir:
            print("❌ Error: --results_dir required for preload demo")
            return
        demo_preload_data(args.results_dir)
    elif args.demo == "custom":
        demo_custom_settings(args.results_dir)
    elif args.demo == "programmatic":
        demo_programmatic_access()


if __name__ == "__main__":
    main()