Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -239,25 +239,24 @@ def create_app():
|
|
| 239 |
# Spaces will automatically detect Gradio and run this
|
| 240 |
# The demo variable must be exposed at module level for Spaces to detect it
|
| 241 |
|
| 242 |
-
#
|
| 243 |
-
demo
|
|
|
|
| 244 |
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
-
|
| 255 |
-
if demo is None:
|
| 256 |
-
raise ValueError("Demo object is None after creation")
|
| 257 |
-
if not hasattr(demo, 'launch'):
|
| 258 |
-
raise ValueError("Demo object does not have launch method")
|
| 259 |
-
|
| 260 |
-
except Exception as e:
|
| 261 |
print(f"β Fatal error creating app: {e}")
|
| 262 |
import traceback
|
| 263 |
traceback.print_exc()
|
|
@@ -290,8 +289,8 @@ if demo is None:
|
|
| 290 |
description="An error occurred. Please check the logs."
|
| 291 |
)
|
| 292 |
|
| 293 |
-
#
|
| 294 |
-
if demo is None:
|
| 295 |
import gradio as gr
|
| 296 |
demo = gr.Interface(
|
| 297 |
fn=lambda: "Application failed to initialize. Please check the logs.",
|
|
|
|
| 239 |
# Spaces will automatically detect Gradio and run this
|
| 240 |
# The demo variable must be exposed at module level for Spaces to detect it
|
| 241 |
|
| 242 |
+
# Create demo object for Hugging Face Spaces
|
| 243 |
+
# Spaces will automatically detect and launch the demo object
|
| 244 |
+
# We use a simple approach: create demo directly at module level
|
| 245 |
|
| 246 |
+
try:
|
| 247 |
+
print("π Starting app initialization...")
|
| 248 |
+
demo = create_app()
|
| 249 |
+
print("β
App created successfully!")
|
| 250 |
+
print(f"β
Demo type: {type(demo)}")
|
| 251 |
+
print(f"β
Demo object: {demo}")
|
| 252 |
+
|
| 253 |
+
# Verify demo is a valid Gradio Blocks object
|
| 254 |
+
if demo is None:
|
| 255 |
+
raise ValueError("Demo object is None after creation")
|
| 256 |
+
if not hasattr(demo, 'launch'):
|
| 257 |
+
raise ValueError("Demo object does not have launch method")
|
| 258 |
|
| 259 |
+
except Exception as e:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
print(f"β Fatal error creating app: {e}")
|
| 261 |
import traceback
|
| 262 |
traceback.print_exc()
|
|
|
|
| 289 |
description="An error occurred. Please check the logs."
|
| 290 |
)
|
| 291 |
|
| 292 |
+
# Ensure demo is always defined (fallback if all else fails)
|
| 293 |
+
if 'demo' not in globals() or demo is None:
|
| 294 |
import gradio as gr
|
| 295 |
demo = gr.Interface(
|
| 296 |
fn=lambda: "Application failed to initialize. Please check the logs.",
|