makiling commited on
Commit
d7fc5fc
·
verified ·
1 Parent(s): ff0f03e

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -51,6 +51,8 @@ def _predict_single(
51
  "heavy_seq": heavy_seq,
52
  "light_seq": light_seq,
53
  }
 
 
54
  preds = predict_batch(
55
  [record],
56
  weights=model_path,
@@ -58,6 +60,7 @@ def _predict_single(
58
  backend=backend or None,
59
  config=DEFAULT_CONFIG_PATH if DEFAULT_CONFIG_PATH.exists() else None,
60
  )
 
61
  score = float(preds.iloc[0]["score"])
62
  pred = int(preds.iloc[0]["pred"])
63
  label = "Polyreactive" if pred == 1 else "Non-polyreactive"
@@ -130,6 +133,8 @@ def _predict_batch(
130
  raise gr.Error("CSV must include at least 'id' and 'heavy_seq' columns.")
131
 
132
  records = frame.to_dict("records")
 
 
133
  preds = predict_batch(
134
  records,
135
  weights=model_path,
@@ -137,6 +142,7 @@ def _predict_batch(
137
  backend=backend or None,
138
  config=DEFAULT_CONFIG_PATH if DEFAULT_CONFIG_PATH.exists() else None,
139
  )
 
140
  merged = frame.merge(preds, on="id", how="left")
141
  output_path = input_path.parent / "polyreact_predictions.csv"
142
  merged.to_csv(output_path, index=False)
@@ -231,6 +237,7 @@ def make_interface() -> gr.Blocks:
231
  - CSV inputs should include `id`, `heavy_seq`, and optionally `light_seq`.
232
  - Add a binary `label` column to compute accuracy/F1/ROC-AUC/PR-AUC/Brier.
233
  - Include `reactivity_count` to report Spearman correlation with predicted probabilities.
 
234
  """
235
  )
236
 
 
51
  "heavy_seq": heavy_seq,
52
  "light_seq": light_seq,
53
  }
54
+ progress = gr.Progress(track_tqdm=True)
55
+ progress(0.05, "Loading model and embeddings (first run may download ESM-1v, please wait)…")
56
  preds = predict_batch(
57
  [record],
58
  weights=model_path,
 
60
  backend=backend or None,
61
  config=DEFAULT_CONFIG_PATH if DEFAULT_CONFIG_PATH.exists() else None,
62
  )
63
+ progress(1.0, "Prediction complete")
64
  score = float(preds.iloc[0]["score"])
65
  pred = int(preds.iloc[0]["pred"])
66
  label = "Polyreactive" if pred == 1 else "Non-polyreactive"
 
133
  raise gr.Error("CSV must include at least 'id' and 'heavy_seq' columns.")
134
 
135
  records = frame.to_dict("records")
136
+ progress = gr.Progress(track_tqdm=True)
137
+ progress(0.05, "Loading model and embeddings (first run may download ESM-1v, please wait)…")
138
  preds = predict_batch(
139
  records,
140
  weights=model_path,
 
142
  backend=backend or None,
143
  config=DEFAULT_CONFIG_PATH if DEFAULT_CONFIG_PATH.exists() else None,
144
  )
145
+ progress(1.0, "Batch prediction complete")
146
  merged = frame.merge(preds, on="id", how="left")
147
  output_path = input_path.parent / "polyreact_predictions.csv"
148
  merged.to_csv(output_path, index=False)
 
237
  - CSV inputs should include `id`, `heavy_seq`, and optionally `light_seq`.
238
  - Add a binary `label` column to compute accuracy/F1/ROC-AUC/PR-AUC/Brier.
239
  - Include `reactivity_count` to report Spearman correlation with predicted probabilities.
240
+ - Initial runs may spend a few minutes downloading the 650M-parameter ESM-1v model before predictions start.
241
  """
242
  )
243