arahrooh commited on
Commit
310c12d
·
1 Parent(s): d9346eb

Fix: Add explicit demo verification and export for Spaces

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -1076,6 +1076,24 @@ if demo is None or not isinstance(demo, (gr.Blocks, gr.Interface)):
1076
  Please check the logs for details.
1077
  """)
1078
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1079
  # For local execution only (not on Spaces)
1080
  if __name__ == "__main__":
1081
  if not IS_SPACES:
 
1076
  Please check the logs for details.
1077
  """)
1078
 
1079
+ # CRITICAL FOR SPACES: Explicitly verify and expose the demo
1080
+ # Make sure it's accessible at module level
1081
+ if IS_SPACES:
1082
+ logger.info("=" * 80)
1083
+ logger.info("SPACES MODE: Final demo verification")
1084
+ logger.info(f"Demo type: {type(demo)}")
1085
+ logger.info(f"Demo is None: {demo is None}")
1086
+ logger.info(f"Demo is valid: {isinstance(demo, (gr.Blocks, gr.Interface))}")
1087
+ logger.info("=" * 80)
1088
+
1089
+ # Explicitly set it again to ensure it's at module level
1090
+ if isinstance(demo, (gr.Blocks, gr.Interface)):
1091
+ # Make sure demo is accessible
1092
+ __all__ = ['demo'] # Explicitly export demo
1093
+ logger.info("Demo is ready for Spaces")
1094
+ else:
1095
+ logger.error("CRITICAL: Demo is not valid even after all checks!")
1096
+
1097
  # For local execution only (not on Spaces)
1098
  if __name__ == "__main__":
1099
  if not IS_SPACES: