File size: 1,190 Bytes
f0e5caa
 
 
 
 
 
 
 
 
 
 
 
 
e98e167
f0e5caa
a15f28f
e98e167
 
a15f28f
e98e167
 
 
 
 
 
 
 
 
 
 
 
a15f28f
f0e5caa
 
 
 
 
 
 
 
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
import sys
import os.path as osp

root_path = osp.abspath(osp.join(__file__, osp.pardir))
sys.path.append(root_path)

from gradio_app import create_gradio_interface

def main():
    """Main function to launch the Gradio interface."""
    try:
        demo = create_gradio_interface()

        # For Hugging Face Spaces deployment - always use share=True for safety
        import os

        print("🚀 Launching PupilSense...")
        print(f"Environment variables: SPACE_ID={os.getenv('SPACE_ID')}, SYSTEM={os.getenv('SYSTEM')}")

        # Always use share=True for HF Spaces compatibility
        try:
            demo.launch(
                server_name="0.0.0.0",
                server_port=7860,
                share=True,
                show_error=True,
                quiet=False
            )
        except Exception as launch_error:
            print(f"Launch failed with share=True, trying basic launch: {launch_error}")
            # Fallback to most basic launch
            demo.launch()
    except Exception as e:
        print(f"Error launching app: {e}")
        import traceback
        traceback.print_exc()
        raise e

if __name__ == "__main__":
    main()