Spaces:
Sleeping
Sleeping
Update app/main.py
Browse files- app/main.py +17 -0
app/main.py
CHANGED
|
@@ -4,6 +4,23 @@ from fastapi.middleware.wsgi import WSGIMiddleware # Nicht direkt benötigt für
|
|
| 4 |
import gradio as gr
|
| 5 |
from ui import create_ui
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from pydantic import BaseModel
|
| 8 |
BaseModel.model_config = {"arbitrary_types_allowed": True}
|
| 9 |
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from ui import create_ui
|
| 6 |
|
| 7 |
+
APP_CACHE_BASE_DIR = "/app/.model_cache"
|
| 8 |
+
try:
|
| 9 |
+
os.makedirs(APP_CACHE_BASE_DIR, exist_ok=True)
|
| 10 |
+
# ... (Schreibtest wie oben) ...
|
| 11 |
+
print(f"Schreibtest in '{APP_CACHE_BASE_DIR}' erfolgreich. Setze HF_HOME.")
|
| 12 |
+
os.environ['HF_HOME'] = APP_CACHE_BASE_DIR
|
| 13 |
+
except Exception as e:
|
| 14 |
+
print(f"FEHLER: {APP_CACHE_BASE_DIR} ist nicht beschreibbar oder konnte nicht erstellt werden: {e}")
|
| 15 |
+
# Fallback auf /tmp oder Fehlerbehandlung
|
| 16 |
+
tmp_cache_dir = "/tmp/.huggingface_cache_coachplugin"
|
| 17 |
+
try:
|
| 18 |
+
os.makedirs(tmp_cache_dir, exist_ok=True)
|
| 19 |
+
os.environ['HF_HOME'] = tmp_cache_dir
|
| 20 |
+
print(f"Fallback: HF_HOME auf {tmp_cache_dir} gesetzt.")
|
| 21 |
+
except Exception as e_tmp:
|
| 22 |
+
print(f"FEHLER: Auch Fallback auf {tmp_cache_dir} fehlgeschlagen: {e_tmp}")
|
| 23 |
+
|
| 24 |
from pydantic import BaseModel
|
| 25 |
BaseModel.model_config = {"arbitrary_types_allowed": True}
|
| 26 |
|