Spaces:
Sleeping
Sleeping
gradio version check 2
Browse files
app.py
CHANGED
|
@@ -13,11 +13,24 @@ def main():
|
|
| 13 |
|
| 14 |
# For Hugging Face Spaces deployment
|
| 15 |
import os
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
else:
|
| 20 |
# Running locally
|
|
|
|
| 21 |
try:
|
| 22 |
demo.launch(
|
| 23 |
server_name="0.0.0.0",
|
|
|
|
| 13 |
|
| 14 |
# For Hugging Face Spaces deployment
|
| 15 |
import os
|
| 16 |
+
|
| 17 |
+
# Multiple ways to detect Hugging Face Spaces environment
|
| 18 |
+
is_hf_spaces = (
|
| 19 |
+
os.getenv("SPACE_ID") is not None or
|
| 20 |
+
os.getenv("SYSTEM") == "spaces" or
|
| 21 |
+
os.getenv("SPACE_AUTHOR_NAME") is not None or
|
| 22 |
+
os.getenv("SPACE_REPO_NAME") is not None or
|
| 23 |
+
"hf.space" in os.getenv("SPACE_HOST", "") or
|
| 24 |
+
os.path.exists("/home/user") # HF Spaces user directory
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
if is_hf_spaces:
|
| 28 |
+
# Running on Hugging Face Spaces - use default settings
|
| 29 |
+
print("🚀 Detected Hugging Face Spaces environment")
|
| 30 |
+
demo.launch()
|
| 31 |
else:
|
| 32 |
# Running locally
|
| 33 |
+
print("🏠 Running in local environment")
|
| 34 |
try:
|
| 35 |
demo.launch(
|
| 36 |
server_name="0.0.0.0",
|