Commit
·
99dc0b1
1
Parent(s):
676848c
Add theme-aware logo swap
Browse files- app.py +72 -10
- assets/RaidDark.svg +13 -0
- assets/RaidLight.svg +13 -0
- assets/ReportAId.svg +0 -26
app.py
CHANGED
|
@@ -1188,23 +1188,85 @@ def create_interface():
|
|
| 1188 |
model_id = get_env_or_secret("HF_MODEL_ID", "ReportAId/whisper-medium-it-finetuned")
|
| 1189 |
base_model_id = get_env_or_secret("BASE_WHISPER_MODEL_ID", "openai/whisper-medium")
|
| 1190 |
|
| 1191 |
-
# Carica
|
| 1192 |
logo_html = None
|
| 1193 |
try:
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1198 |
logo_html = f"""
|
| 1199 |
-
<
|
| 1200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1201 |
</div>
|
| 1202 |
"""
|
| 1203 |
except Exception:
|
| 1204 |
-
# Fallback
|
| 1205 |
logo_html = """
|
| 1206 |
-
<
|
| 1207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1208 |
</div>
|
| 1209 |
"""
|
| 1210 |
|
|
|
|
| 1188 |
model_id = get_env_or_secret("HF_MODEL_ID", "ReportAId/whisper-medium-it-finetuned")
|
| 1189 |
base_model_id = get_env_or_secret("BASE_WHISPER_MODEL_ID", "openai/whisper-medium")
|
| 1190 |
|
| 1191 |
+
# Carica i loghi chiaro/scuro inline e alterna in base al tema preferito
|
| 1192 |
logo_html = None
|
| 1193 |
try:
|
| 1194 |
+
assets_dir = os.path.join(os.path.dirname(__file__), "assets")
|
| 1195 |
+
light_path = os.path.join(assets_dir, "RaidLight.svg")
|
| 1196 |
+
dark_path = os.path.join(assets_dir, "RaidDark.svg")
|
| 1197 |
+
|
| 1198 |
+
with open(light_path, "r", encoding="utf-8") as f:
|
| 1199 |
+
light_svg = f.read()
|
| 1200 |
+
with open(dark_path, "r", encoding="utf-8") as f:
|
| 1201 |
+
dark_svg = f.read()
|
| 1202 |
+
|
| 1203 |
logo_html = f"""
|
| 1204 |
+
<style>
|
| 1205 |
+
.logo-container {{
|
| 1206 |
+
text-align: center;
|
| 1207 |
+
margin: 16px 0 8px;
|
| 1208 |
+
}}
|
| 1209 |
+
.logo-container .sr-only {{
|
| 1210 |
+
position: absolute;
|
| 1211 |
+
width: 1px;
|
| 1212 |
+
height: 1px;
|
| 1213 |
+
padding: 0;
|
| 1214 |
+
margin: -1px;
|
| 1215 |
+
overflow: hidden;
|
| 1216 |
+
clip: rect(0, 0, 0, 0);
|
| 1217 |
+
white-space: nowrap;
|
| 1218 |
+
border: 0;
|
| 1219 |
+
}}
|
| 1220 |
+
.logo-container svg {{
|
| 1221 |
+
height: 72px;
|
| 1222 |
+
width: auto;
|
| 1223 |
+
max-width: 100%;
|
| 1224 |
+
}}
|
| 1225 |
+
.logo-container .logo-dark {{
|
| 1226 |
+
display: none;
|
| 1227 |
+
}}
|
| 1228 |
+
@media (prefers-color-scheme: dark) {{
|
| 1229 |
+
.logo-container .logo-light {{
|
| 1230 |
+
display: none !important;
|
| 1231 |
+
}}
|
| 1232 |
+
.logo-container .logo-dark {{
|
| 1233 |
+
display: inline-block !important;
|
| 1234 |
+
}}
|
| 1235 |
+
}}
|
| 1236 |
+
</style>
|
| 1237 |
+
<div class=\"logo-container\">
|
| 1238 |
+
<div class=\"logo-light\" aria-hidden=\"true\">{light_svg}</div>
|
| 1239 |
+
<div class=\"logo-dark\" aria-hidden=\"true\">{dark_svg}</div>
|
| 1240 |
+
<span class=\"sr-only\">ReportAId</span>
|
| 1241 |
</div>
|
| 1242 |
"""
|
| 1243 |
except Exception:
|
| 1244 |
+
# Fallback: immagini servite dal path file= con switch CSS
|
| 1245 |
logo_html = """
|
| 1246 |
+
<style>
|
| 1247 |
+
.logo-container { text-align: center; margin: 16px 0 8px; }
|
| 1248 |
+
.logo-container .sr-only {
|
| 1249 |
+
position: absolute;
|
| 1250 |
+
width: 1px;
|
| 1251 |
+
height: 1px;
|
| 1252 |
+
padding: 0;
|
| 1253 |
+
margin: -1px;
|
| 1254 |
+
overflow: hidden;
|
| 1255 |
+
clip: rect(0, 0, 0, 0);
|
| 1256 |
+
white-space: nowrap;
|
| 1257 |
+
border: 0;
|
| 1258 |
+
}
|
| 1259 |
+
.logo-container img { height: 72px; width: auto; max-width: 100%; }
|
| 1260 |
+
.logo-container .logo-dark { display: none; }
|
| 1261 |
+
@media (prefers-color-scheme: dark) {
|
| 1262 |
+
.logo-container .logo-light { display: none !important; }
|
| 1263 |
+
.logo-container .logo-dark { display: inline-block !important; }
|
| 1264 |
+
}
|
| 1265 |
+
</style>
|
| 1266 |
+
<div class=\"logo-container\">
|
| 1267 |
+
<img class=\"logo-light\" src=\"file=assets/RaidLight.svg\" alt=\"ReportAId\">
|
| 1268 |
+
<img class=\"logo-dark\" src=\"file=assets/RaidDark.svg\" alt=\"ReportAId\">
|
| 1269 |
+
<span class=\"sr-only\">ReportAId</span>
|
| 1270 |
</div>
|
| 1271 |
"""
|
| 1272 |
|
assets/RaidDark.svg
ADDED
|
|
assets/RaidLight.svg
ADDED
|
|
assets/ReportAId.svg
DELETED