From-Image: gallery shows the input plots (not pre-rendered outputs); add note that digitized curves often trigger OOD
Browse files
app.py
CHANGED
|
@@ -1038,7 +1038,11 @@ def build_app():
|
|
| 1038 |
gr.HTML(
|
| 1039 |
"<p class='helper'>One image per scan rate (potential on x-axis, "
|
| 1040 |
"current on y-axis). Axis bounds auto-detected via OCR — "
|
| 1041 |
-
"override in Advanced if needed.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1042 |
)
|
| 1043 |
if CV_IMG_EXAMPLES:
|
| 1044 |
with gr.Row():
|
|
@@ -1053,7 +1057,7 @@ def build_app():
|
|
| 1053 |
"Load", variant="secondary", scale=1,
|
| 1054 |
)
|
| 1055 |
cv_img_example_gallery = gr.Gallery(
|
| 1056 |
-
label="
|
| 1057 |
columns=3, height=220, object_fit="contain",
|
| 1058 |
interactive=False,
|
| 1059 |
)
|
|
@@ -1165,15 +1169,15 @@ def build_app():
|
|
| 1165 |
outputs=[cv_img_posteriors, cv_img_param_table, cv_img_recon, cv_img_conc],
|
| 1166 |
)
|
| 1167 |
if CV_IMG_EXAMPLES:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1168 |
def _on_cv_img_example_select(mech_name):
|
| 1169 |
files, rates = _load_cv_image_example(mech_name)
|
| 1170 |
-
|
| 1171 |
-
gallery_imgs = [
|
| 1172 |
-
renders[k] for k in
|
| 1173 |
-
["classification", "posteriors", "reconstruction"]
|
| 1174 |
-
if k in renders
|
| 1175 |
-
]
|
| 1176 |
-
return files, rates, gallery_imgs
|
| 1177 |
|
| 1178 |
cv_img_example_btn.click(
|
| 1179 |
_on_cv_img_example_select,
|
|
@@ -1181,11 +1185,7 @@ def build_app():
|
|
| 1181 |
outputs=[cv_img_files, cv_img_scan_rate, cv_img_example_gallery],
|
| 1182 |
)
|
| 1183 |
cv_img_example_dd.change(
|
| 1184 |
-
|
| 1185 |
-
CV_OUTPUT_RENDERS.get(m, {}).get(k)
|
| 1186 |
-
for k in ["classification", "posteriors", "reconstruction"]
|
| 1187 |
-
if CV_OUTPUT_RENDERS.get(m, {}).get(k)
|
| 1188 |
-
],
|
| 1189 |
inputs=[cv_img_example_dd],
|
| 1190 |
outputs=[cv_img_example_gallery],
|
| 1191 |
)
|
|
@@ -1254,7 +1254,11 @@ def build_app():
|
|
| 1254 |
gr.HTML(
|
| 1255 |
"<p class='helper'>One image per heating rate (temperature on "
|
| 1256 |
"x-axis, signal on y-axis). Axis bounds auto-detected via OCR "
|
| 1257 |
-
"— override in Advanced if needed.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1258 |
)
|
| 1259 |
if TPD_IMG_EXAMPLES:
|
| 1260 |
with gr.Row():
|
|
@@ -1269,7 +1273,7 @@ def build_app():
|
|
| 1269 |
"Load", variant="secondary", scale=1,
|
| 1270 |
)
|
| 1271 |
tpd_img_example_gallery = gr.Gallery(
|
| 1272 |
-
label="
|
| 1273 |
columns=3, height=220, object_fit="contain",
|
| 1274 |
interactive=False,
|
| 1275 |
)
|
|
@@ -1361,15 +1365,14 @@ def build_app():
|
|
| 1361 |
outputs=[tpd_img_posteriors, tpd_img_param_table, tpd_img_recon],
|
| 1362 |
)
|
| 1363 |
if TPD_IMG_EXAMPLES:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1364 |
def _on_tpd_img_example_select(mech_name):
|
| 1365 |
files, betas = _load_tpd_image_example(mech_name)
|
| 1366 |
-
|
| 1367 |
-
gallery_imgs = [
|
| 1368 |
-
renders[k] for k in
|
| 1369 |
-
["classification", "posteriors", "reconstruction"]
|
| 1370 |
-
if k in renders
|
| 1371 |
-
]
|
| 1372 |
-
return files, betas, gallery_imgs
|
| 1373 |
|
| 1374 |
tpd_img_example_btn.click(
|
| 1375 |
_on_tpd_img_example_select,
|
|
@@ -1377,11 +1380,7 @@ def build_app():
|
|
| 1377 |
outputs=[tpd_img_files, tpd_img_betas, tpd_img_example_gallery],
|
| 1378 |
)
|
| 1379 |
tpd_img_example_dd.change(
|
| 1380 |
-
|
| 1381 |
-
TPD_OUTPUT_RENDERS.get(m, {}).get(k)
|
| 1382 |
-
for k in ["classification", "posteriors", "reconstruction"]
|
| 1383 |
-
if TPD_OUTPUT_RENDERS.get(m, {}).get(k)
|
| 1384 |
-
],
|
| 1385 |
inputs=[tpd_img_example_dd],
|
| 1386 |
outputs=[tpd_img_example_gallery],
|
| 1387 |
)
|
|
|
|
| 1038 |
gr.HTML(
|
| 1039 |
"<p class='helper'>One image per scan rate (potential on x-axis, "
|
| 1040 |
"current on y-axis). Axis bounds auto-detected via OCR — "
|
| 1041 |
+
"override in Advanced if needed. "
|
| 1042 |
+
"<em>Note:</em> digitized curves are inherently noisier than the "
|
| 1043 |
+
"simulated data the model was trained on, so the OOD detector may "
|
| 1044 |
+
"flag image inputs and reconstruction quality is typically lower "
|
| 1045 |
+
"than the CSV path; for production use, prefer CSV.</p>"
|
| 1046 |
)
|
| 1047 |
if CV_IMG_EXAMPLES:
|
| 1048 |
with gr.Row():
|
|
|
|
| 1057 |
"Load", variant="secondary", scale=1,
|
| 1058 |
)
|
| 1059 |
cv_img_example_gallery = gr.Gallery(
|
| 1060 |
+
label="Input plot images (one per scan rate) \u2014 these are what the model digitizes",
|
| 1061 |
columns=3, height=220, object_fit="contain",
|
| 1062 |
interactive=False,
|
| 1063 |
)
|
|
|
|
| 1169 |
outputs=[cv_img_posteriors, cv_img_param_table, cv_img_recon, cv_img_conc],
|
| 1170 |
)
|
| 1171 |
if CV_IMG_EXAMPLES:
|
| 1172 |
+
def _cv_img_input_gallery(mech_name):
|
| 1173 |
+
"""Show the actual input PNGs the user will analyze."""
|
| 1174 |
+
if not mech_name or mech_name not in CV_IMG_EXAMPLES:
|
| 1175 |
+
return []
|
| 1176 |
+
return [e[0] for e in CV_IMG_EXAMPLES[mech_name]]
|
| 1177 |
+
|
| 1178 |
def _on_cv_img_example_select(mech_name):
|
| 1179 |
files, rates = _load_cv_image_example(mech_name)
|
| 1180 |
+
return files, rates, _cv_img_input_gallery(mech_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1181 |
|
| 1182 |
cv_img_example_btn.click(
|
| 1183 |
_on_cv_img_example_select,
|
|
|
|
| 1185 |
outputs=[cv_img_files, cv_img_scan_rate, cv_img_example_gallery],
|
| 1186 |
)
|
| 1187 |
cv_img_example_dd.change(
|
| 1188 |
+
_cv_img_input_gallery,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1189 |
inputs=[cv_img_example_dd],
|
| 1190 |
outputs=[cv_img_example_gallery],
|
| 1191 |
)
|
|
|
|
| 1254 |
gr.HTML(
|
| 1255 |
"<p class='helper'>One image per heating rate (temperature on "
|
| 1256 |
"x-axis, signal on y-axis). Axis bounds auto-detected via OCR "
|
| 1257 |
+
"— override in Advanced if needed. "
|
| 1258 |
+
"<em>Note:</em> digitized curves are inherently noisier than the "
|
| 1259 |
+
"simulated data the model was trained on, so the OOD detector may "
|
| 1260 |
+
"flag image inputs and reconstruction quality is typically lower "
|
| 1261 |
+
"than the CSV path; for production use, prefer CSV.</p>"
|
| 1262 |
)
|
| 1263 |
if TPD_IMG_EXAMPLES:
|
| 1264 |
with gr.Row():
|
|
|
|
| 1273 |
"Load", variant="secondary", scale=1,
|
| 1274 |
)
|
| 1275 |
tpd_img_example_gallery = gr.Gallery(
|
| 1276 |
+
label="Input plot image \u2014 this is what the model digitizes",
|
| 1277 |
columns=3, height=220, object_fit="contain",
|
| 1278 |
interactive=False,
|
| 1279 |
)
|
|
|
|
| 1365 |
outputs=[tpd_img_posteriors, tpd_img_param_table, tpd_img_recon],
|
| 1366 |
)
|
| 1367 |
if TPD_IMG_EXAMPLES:
|
| 1368 |
+
def _tpd_img_input_gallery(mech_name):
|
| 1369 |
+
if not mech_name or mech_name not in TPD_IMG_EXAMPLES:
|
| 1370 |
+
return []
|
| 1371 |
+
return [e[0] for e in TPD_IMG_EXAMPLES[mech_name]]
|
| 1372 |
+
|
| 1373 |
def _on_tpd_img_example_select(mech_name):
|
| 1374 |
files, betas = _load_tpd_image_example(mech_name)
|
| 1375 |
+
return files, betas, _tpd_img_input_gallery(mech_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1376 |
|
| 1377 |
tpd_img_example_btn.click(
|
| 1378 |
_on_tpd_img_example_select,
|
|
|
|
| 1380 |
outputs=[tpd_img_files, tpd_img_betas, tpd_img_example_gallery],
|
| 1381 |
)
|
| 1382 |
tpd_img_example_dd.change(
|
| 1383 |
+
_tpd_img_input_gallery,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1384 |
inputs=[tpd_img_example_dd],
|
| 1385 |
outputs=[tpd_img_example_gallery],
|
| 1386 |
)
|