Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,10 @@ import time
|
|
| 4 |
import sys
|
| 5 |
import shutil
|
| 6 |
from pathlib import Path
|
|
|
|
| 7 |
|
|
|
|
|
|
|
| 8 |
# ==========================================================
|
| 9 |
if os.environ.get("SPACE_ID"):
|
| 10 |
# Fix für Rendering: Xvfb nur starten, wenn noch nicht aktiv
|
|
@@ -21,11 +24,21 @@ if os.environ.get("SPACE_ID"):
|
|
| 21 |
"MESA_GL_VERSION_OVERRIDE": "4.1"
|
| 22 |
})
|
| 23 |
|
| 24 |
-
# Fix
|
| 25 |
import gradio_client.utils as client_utils
|
| 26 |
client_utils._json_schema_to_python_type = lambda *args, **kwargs: "Any"
|
| 27 |
client_utils.json_schema_to_python_type = lambda *args, **kwargs: "Any"
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# ==========================================================
|
| 30 |
# 2. CORE IMPORTS (Erst nach dem Setup!)
|
| 31 |
# ==========================================================
|
|
|
|
| 4 |
import sys
|
| 5 |
import shutil
|
| 6 |
from pathlib import Path
|
| 7 |
+
from unittest.mock import MagicMock
|
| 8 |
|
| 9 |
+
# ==========================================================
|
| 10 |
+
# 1. SETUP & BUGFIXES
|
| 11 |
# ==========================================================
|
| 12 |
if os.environ.get("SPACE_ID"):
|
| 13 |
# Fix für Rendering: Xvfb nur starten, wenn noch nicht aktiv
|
|
|
|
| 24 |
"MESA_GL_VERSION_OVERRIDE": "4.1"
|
| 25 |
})
|
| 26 |
|
| 27 |
+
# Fix A: Gradio Schema-Fehler
|
| 28 |
import gradio_client.utils as client_utils
|
| 29 |
client_utils._json_schema_to_python_type = lambda *args, **kwargs: "Any"
|
| 30 |
client_utils.json_schema_to_python_type = lambda *args, **kwargs: "Any"
|
| 31 |
|
| 32 |
+
# Fix B: Flash Attention Mocking (verhindert ImportError)
|
| 33 |
+
try:
|
| 34 |
+
import flash_attn
|
| 35 |
+
except ImportError:
|
| 36 |
+
mock = MagicMock()
|
| 37 |
+
sys.modules["flash_attn"] = mock
|
| 38 |
+
sys.modules["flash_attn.modules"] = mock
|
| 39 |
+
sys.modules["flash_attn.modules.mha"] = mock
|
| 40 |
+
print("Flash Attention not found, using Mock for compatibility.")
|
| 41 |
+
|
| 42 |
# ==========================================================
|
| 43 |
# 2. CORE IMPORTS (Erst nach dem Setup!)
|
| 44 |
# ==========================================================
|