Mulah commited on
Commit
6f6cbbd
·
1 Parent(s): e90e039

UI polish: logo, human-readable reliability, default ubiquitin sequence

Browse files
Files changed (2) hide show
  1. app.py +24 -5
  2. prottale_logo.png +0 -0
app.py CHANGED
@@ -132,16 +132,35 @@ def predict(sequence: str):
132
  pred = pred_texts[0]
133
  r = float(r_pred.cpu().tolist()[0] if torch.is_tensor(r_pred) else r_pred[0])
134
  p1 = float(r_prob_class1.cpu().tolist()[0] if torch.is_tensor(r_prob_class1) else r_prob_class1[0])
135
- return pred, f"{r:.4f}", f"{p1:.4f}"
136
 
137
 
138
  EXAMPLE_SEQ = (
139
- "MKTVRQERLKSIVRILERSKEPVSGAQLAEELSVSRQVIVQDIAYLRSLGYNIVATPRGYVLAGG"
140
  )
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  with gr.Blocks(title="ProtTale") as demo:
 
 
 
 
 
 
 
143
  gr.Markdown(
144
- "# ProtTale\n"
145
  "Protein amino-acid sequence → Swiss-Prot-style function description, "
146
  "with a reliability score for the generated text.\n\n"
147
  "**Note:** this Space runs on CPU; a single beam-3 generation typically takes ~30–120 s."
@@ -151,8 +170,8 @@ with gr.Blocks(title="ProtTale") as demo:
151
  run_btn = gr.Button("Predict", variant="primary")
152
  with gr.Column():
153
  pred_out = gr.Textbox(label="Predicted function")
154
- r_out = gr.Textbox(label="Reliability class (−1 / 0 / 0.5 / 1)")
155
- p_out = gr.Textbox(label="P(reliability = 1.0)")
156
 
157
  run_btn.click(predict, inputs=[seq_in], outputs=[pred_out, r_out, p_out])
158
 
 
132
  pred = pred_texts[0]
133
  r = float(r_pred.cpu().tolist()[0] if torch.is_tensor(r_pred) else r_pred[0])
134
  p1 = float(r_prob_class1.cpu().tolist()[0] if torch.is_tensor(r_prob_class1) else r_prob_class1[0])
135
+ return pred, format_reliability(r), f"{p1:.4f}"
136
 
137
 
138
  EXAMPLE_SEQ = (
139
+ "MQIFVKTLTGKTITLEVEPSDTIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLHLVLRLRGG"
140
  )
141
 
142
+ RELIABILITY_LABELS = {
143
+ 1.0: "High-confidence correct",
144
+ 0.0: "High-confidence incorrect",
145
+ 0.5: "Uncertain",
146
+ -1.0: "Vague",
147
+ }
148
+
149
+
150
+ def format_reliability(r: float) -> str:
151
+ label = RELIABILITY_LABELS.get(r, "Unknown")
152
+ return f"{label} (class={r:g})"
153
+
154
+
155
  with gr.Blocks(title="ProtTale") as demo:
156
+ gr.Image(
157
+ value="prottale_logo.png",
158
+ show_label=False,
159
+ show_download_button=False,
160
+ container=False,
161
+ height=120,
162
+ )
163
  gr.Markdown(
 
164
  "Protein amino-acid sequence → Swiss-Prot-style function description, "
165
  "with a reliability score for the generated text.\n\n"
166
  "**Note:** this Space runs on CPU; a single beam-3 generation typically takes ~30–120 s."
 
170
  run_btn = gr.Button("Predict", variant="primary")
171
  with gr.Column():
172
  pred_out = gr.Textbox(label="Predicted function")
173
+ r_out = gr.Textbox(label="Reliability")
174
+ p_out = gr.Textbox(label="P(high-confidence correct)")
175
 
176
  run_btn.click(predict, inputs=[seq_in], outputs=[pred_out, r_out, p_out])
177
 
prottale_logo.png ADDED