Spaces:
Running
on
Zero
Running
on
Zero
| import sys | |
| import warnings | |
| warnings.filterwarnings("ignore") | |
| from ui_manager import UIManager | |
| def launch_final_blend_sceneweaver(share: bool = True, debug: bool = False): | |
| """Launch SceneWeaver Application""" | |
| print("π¨ Starting SceneWeaver...") | |
| print("β¨ AI-Powered Image Background Generation") | |
| try: | |
| # Test imports first | |
| print("π Testing imports...") | |
| try: | |
| # Test creating UIManager | |
| print("π Creating UIManager instance...") | |
| ui = UIManager() | |
| print("β UIManager instance created successfully") | |
| # Launch UI | |
| print("π Launching interface...") | |
| interface = ui.launch(share=share, debug=debug) | |
| print("β Interface launched successfully") | |
| return interface | |
| except ImportError as import_error: | |
| import traceback | |
| print(f"β Import failed: {import_error}") | |
| print(f"Traceback: {traceback.format_exc()}") | |
| raise | |
| except Exception as e: | |
| import traceback | |
| print(f"β Failed to launch: {e}") | |
| print(f"Full traceback: {traceback.format_exc()}") | |
| raise | |
| def launch_ui(share: bool = True, debug: bool = False): | |
| """Convenience function for Jupyter notebooks""" | |
| return launch_final_blend_sceneweaver(share=share, debug=debug) | |
| def main(): | |
| """Main entry point""" | |
| # Check if running in Jupyter/Colab | |
| try: | |
| get_ipython() | |
| is_jupyter = True | |
| except NameError: | |
| is_jupyter = False | |
| if not is_jupyter and len(sys.argv) > 1 and not any('-f' in arg for arg in sys.argv): | |
| # Command line mode with arguments | |
| share = '--no-share' not in sys.argv | |
| debug = '--debug' in sys.argv | |
| else: | |
| # Default mode | |
| share = True | |
| debug = False | |
| try: | |
| interface = launch_final_blend_sceneweaver(share=share, debug=debug) | |
| if not is_jupyter: | |
| print("π Press Ctrl+C to stop") | |
| try: | |
| interface.block_thread() | |
| except KeyboardInterrupt: | |
| print("π Stopped") | |
| return interface | |
| except Exception as e: | |
| print(f"β Error: {e}") | |
| if not is_jupyter: | |
| sys.exit(1) | |
| raise | |
| if __name__ == "__main__": | |
| main() | |