Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
import json
|
|
|
|
| 3 |
import streamlit as st
|
| 4 |
import torch
|
| 5 |
import torch.nn.functional as F
|
|
@@ -8,11 +9,17 @@ import re
|
|
| 8 |
import math
|
| 9 |
import logging
|
| 10 |
|
| 11 |
-
# --- Load heuristic weights from environment secrets ---
|
| 12 |
@st.cache_resource
|
| 13 |
def load_heuristic_weights():
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
return ai, og
|
| 17 |
|
| 18 |
AI_WEIGHTS, OG_WEIGHTS = load_heuristic_weights()
|
|
|
|
| 1 |
import os
|
| 2 |
import json
|
| 3 |
+
import ast
|
| 4 |
import streamlit as st
|
| 5 |
import torch
|
| 6 |
import torch.nn.functional as F
|
|
|
|
| 9 |
import math
|
| 10 |
import logging
|
| 11 |
|
| 12 |
+
# --- Load heuristic weights from environment secrets, with JSON→Python fallback ---
|
| 13 |
@st.cache_resource
|
| 14 |
def load_heuristic_weights():
|
| 15 |
+
def _load(env_key):
|
| 16 |
+
raw = os.environ[env_key]
|
| 17 |
+
try:
|
| 18 |
+
return json.loads(raw)
|
| 19 |
+
except json.JSONDecodeError:
|
| 20 |
+
return ast.literal_eval(raw)
|
| 21 |
+
ai = _load("AI_WEIGHTS_JSON")
|
| 22 |
+
og = _load("OG_WEIGHTS_JSON")
|
| 23 |
return ai, og
|
| 24 |
|
| 25 |
AI_WEIGHTS, OG_WEIGHTS = load_heuristic_weights()
|