File size: 1,356 Bytes
1691ca8
 
 
 
 
 
b38b9a9
1691ca8
 
 
 
 
 
 
 
 
 
 
b38b9a9
 
 
1691ca8
 
b38b9a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6789f6f
b38b9a9
 
 
 
1691ca8
 
 
 
 
 
 
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
"""
TextLens - AI-Powered OCR Application

Main entry point for the application.
"""

import os
import logging
from ui.interface import create_interface

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def main():
    """Main function to launch the application."""
    logger.info("πŸš€ Starting TextLens OCR application...")
    
    # Check if running on HuggingFace Spaces
    is_hf_spaces = os.getenv("SPACE_ID") is not None
    
    try:
        interface = create_interface()
        
        # Configure for HuggingFace Spaces or local deployment
        if is_hf_spaces:
            logger.info("πŸ€— Running on HuggingFace Spaces")
            interface.launch(
                share=False,
                server_name="0.0.0.0",
                server_port=7860,  # HF Spaces default port
                show_error=True
            )
        else:
            logger.info("πŸ’» Running locally")
            interface.launch(
                share=False,
                server_name="0.0.0.0",
                server_port=7860,
                show_error=True,
                favicon_path=None,
                ssl_verify=False
            )
        
    except Exception as e:
        logger.error(f"Failed to start application: {str(e)}")
        raise

if __name__ == "__main__":
    main()