Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -243,7 +243,7 @@ def create_plot(data, label, reg_p, ai_p, overlap):
|
|
| 243 |
tag = " β
OVERLAP" if overlap else ""
|
| 244 |
fig.update_layout(title=f"{label}{tag}",
|
| 245 |
xaxis_title='Drive Amplitude (a.u.)', yaxis_title='Signal (a.u.)',
|
| 246 |
-
height=
|
| 247 |
legend=dict(x=0.01, y=0.99), font=dict(size=13),
|
| 248 |
paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)')
|
| 249 |
return fig
|
|
@@ -520,8 +520,8 @@ def refresh_analytics():
|
|
| 520 |
taggers = list(MONGO_COL.aggregate(tp))
|
| 521 |
tr = "\n".join(f"| {t['_id']} | {t['c']} |" for t in taggers) or "| β | β |"
|
| 522 |
|
| 523 |
-
clf_s = MONGO_DB['experiments_clf_success'].count_documents({}) if MONGO_DB else 0
|
| 524 |
-
clf_f = MONGO_DB['experiments_clf_failed'].count_documents({}) if MONGO_DB else 0
|
| 525 |
|
| 526 |
return f"""### π Platform Statistics
|
| 527 |
| Metric | Count |
|
|
@@ -711,9 +711,7 @@ CSS = """
|
|
| 711 |
.rating-radio label:nth-child(3):has(input:checked) {
|
| 712 |
background: #22c55e !important; color: #fff !important; }
|
| 713 |
|
| 714 |
-
|
| 715 |
-
height: 36px !important; padding: 0 !important; font-size: 16px !important;
|
| 716 |
-
border-radius: 8px !important; margin-top: 28px !important; }
|
| 717 |
"""
|
| 718 |
|
| 719 |
# JavaScript to enable click-to-toggle on radio buttons
|
|
@@ -787,27 +785,22 @@ def build_ui():
|
|
| 787 |
ws_conf = gr.HTML("<p style='color:#888'>Fetch an experiment to begin.</p>")
|
| 788 |
|
| 789 |
gr.Markdown("---")
|
| 790 |
-
gr.Markdown("π‘ **Leave a rating empty = accept model prediction**
|
| 791 |
-
"Select
|
| 792 |
|
| 793 |
-
|
| 794 |
-
with gr.Row():
|
| 795 |
-
with gr.Column(scale=9):
|
| 796 |
-
gr.Markdown("### π Data Quality")
|
| 797 |
-
ws_dr = gr.Radio(choices=RATING_CHOICES, value=None,
|
| 798 |
-
label="Rate raw data:", elem_classes=["rating-radio"])
|
| 799 |
-
dr_clr = gr.Button("β", size="sm", elem_classes=["clear-btn"], scale=0)
|
| 800 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 801 |
ws_cd = gr.Textbox(label="Data notes (optional)", lines=2)
|
| 802 |
|
| 803 |
# Fit Quality β SINGLE (overlap)
|
| 804 |
with gr.Column(visible=True) as ws_fs_col:
|
| 805 |
-
|
| 806 |
-
|
| 807 |
-
|
| 808 |
-
ws_fs = gr.Radio(choices=RATING_CHOICES, value=None,
|
| 809 |
-
label="Rate the fit:", elem_classes=["rating-radio"])
|
| 810 |
-
fs_clr = gr.Button("β", size="sm", elem_classes=["clear-btn"], scale=0)
|
| 811 |
ws_cs = gr.Textbox(label="Fit notes (optional)", lines=2)
|
| 812 |
|
| 813 |
# Fit Quality β DUAL (diverge)
|
|
@@ -816,32 +809,18 @@ def build_ui():
|
|
| 816 |
with gr.Row():
|
| 817 |
with gr.Column():
|
| 818 |
gr.Markdown("#### π¦ Regular Fit")
|
| 819 |
-
|
| 820 |
-
|
| 821 |
-
label="Regular Fit:", elem_classes=["rating-radio"],
|
| 822 |
-
scale=9)
|
| 823 |
-
fr_clr = gr.Button("β", size="sm", elem_classes=["clear-btn"], scale=0)
|
| 824 |
ws_cr = gr.Textbox(label="Regular fit notes", lines=2)
|
| 825 |
with gr.Column():
|
| 826 |
gr.Markdown("#### π© AI Fit")
|
| 827 |
-
|
| 828 |
-
|
| 829 |
-
label="AI Fit:", elem_classes=["rating-radio"],
|
| 830 |
-
scale=9)
|
| 831 |
-
fa_clr = gr.Button("β", size="sm", elem_classes=["clear-btn"], scale=0)
|
| 832 |
ws_ca = gr.Textbox(label="AI fit notes", lines=2)
|
| 833 |
|
| 834 |
gr.Markdown("---")
|
|
|
|
| 835 |
|
| 836 |
-
with gr.Row():
|
| 837 |
-
ws_reset = gr.Button("π Clear All Ratings", size="sm", scale=1)
|
| 838 |
-
ws_submit = gr.Button("π Submit Feedback & Next", variant="primary", scale=3)
|
| 839 |
-
|
| 840 |
-
# Wire clear buttons (individual toggle deselection)
|
| 841 |
-
dr_clr.click(lambda: None, [], [ws_dr])
|
| 842 |
-
fs_clr.click(lambda: None, [], [ws_fs])
|
| 843 |
-
fr_clr.click(lambda: None, [], [ws_fr])
|
| 844 |
-
fa_clr.click(lambda: None, [], [ws_fa])
|
| 845 |
ws_reset.click(reset_ratings, [], [ws_dr, ws_fs, ws_fr, ws_fa])
|
| 846 |
|
| 847 |
# Output list β 18 components
|
|
|
|
| 243 |
tag = " β
OVERLAP" if overlap else ""
|
| 244 |
fig.update_layout(title=f"{label}{tag}",
|
| 245 |
xaxis_title='Drive Amplitude (a.u.)', yaxis_title='Signal (a.u.)',
|
| 246 |
+
height=650, margin=dict(l=60, r=40, t=60, b=60),
|
| 247 |
legend=dict(x=0.01, y=0.99), font=dict(size=13),
|
| 248 |
paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)')
|
| 249 |
return fig
|
|
|
|
| 520 |
taggers = list(MONGO_COL.aggregate(tp))
|
| 521 |
tr = "\n".join(f"| {t['_id']} | {t['c']} |" for t in taggers) or "| β | β |"
|
| 522 |
|
| 523 |
+
clf_s = MONGO_DB['experiments_clf_success'].count_documents({}) if MONGO_DB is not None else 0
|
| 524 |
+
clf_f = MONGO_DB['experiments_clf_failed'].count_documents({}) if MONGO_DB is not None else 0
|
| 525 |
|
| 526 |
return f"""### π Platform Statistics
|
| 527 |
| Metric | Count |
|
|
|
|
| 711 |
.rating-radio label:nth-child(3):has(input:checked) {
|
| 712 |
background: #22c55e !important; color: #fff !important; }
|
| 713 |
|
| 714 |
+
|
|
|
|
|
|
|
| 715 |
"""
|
| 716 |
|
| 717 |
# JavaScript to enable click-to-toggle on radio buttons
|
|
|
|
| 785 |
ws_conf = gr.HTML("<p style='color:#888'>Fetch an experiment to begin.</p>")
|
| 786 |
|
| 787 |
gr.Markdown("---")
|
| 788 |
+
gr.Markdown("π‘ **Leave a rating empty = accept model prediction.** "
|
| 789 |
+
"Select only to correct the model.")
|
| 790 |
|
| 791 |
+
ws_reset = gr.Button("π Clear All Ratings", size="sm")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 792 |
|
| 793 |
+
# Data Quality
|
| 794 |
+
gr.Markdown("### π Data Quality")
|
| 795 |
+
ws_dr = gr.Radio(choices=RATING_CHOICES, value=None,
|
| 796 |
+
label="Rate raw data:", elem_classes=["rating-radio"])
|
| 797 |
ws_cd = gr.Textbox(label="Data notes (optional)", lines=2)
|
| 798 |
|
| 799 |
# Fit Quality β SINGLE (overlap)
|
| 800 |
with gr.Column(visible=True) as ws_fs_col:
|
| 801 |
+
gr.Markdown("### π Fit Quality (Combined)")
|
| 802 |
+
ws_fs = gr.Radio(choices=RATING_CHOICES, value=None,
|
| 803 |
+
label="Rate the fit:", elem_classes=["rating-radio"])
|
|
|
|
|
|
|
|
|
|
| 804 |
ws_cs = gr.Textbox(label="Fit notes (optional)", lines=2)
|
| 805 |
|
| 806 |
# Fit Quality β DUAL (diverge)
|
|
|
|
| 809 |
with gr.Row():
|
| 810 |
with gr.Column():
|
| 811 |
gr.Markdown("#### π¦ Regular Fit")
|
| 812 |
+
ws_fr = gr.Radio(choices=RATING_CHOICES, value=None,
|
| 813 |
+
label="Regular Fit:", elem_classes=["rating-radio"])
|
|
|
|
|
|
|
|
|
|
| 814 |
ws_cr = gr.Textbox(label="Regular fit notes", lines=2)
|
| 815 |
with gr.Column():
|
| 816 |
gr.Markdown("#### π© AI Fit")
|
| 817 |
+
ws_fa = gr.Radio(choices=RATING_CHOICES, value=None,
|
| 818 |
+
label="AI Fit:", elem_classes=["rating-radio"])
|
|
|
|
|
|
|
|
|
|
| 819 |
ws_ca = gr.Textbox(label="AI fit notes", lines=2)
|
| 820 |
|
| 821 |
gr.Markdown("---")
|
| 822 |
+
ws_submit = gr.Button("π Submit Feedback & Next", variant="primary", size="lg")
|
| 823 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 824 |
ws_reset.click(reset_ratings, [], [ws_dr, ws_fs, ws_fr, ws_fa])
|
| 825 |
|
| 826 |
# Output list β 18 components
|