Xianfish9 commited on
Commit
2843ebe
·
verified ·
1 Parent(s): 3511ff8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -62,14 +62,14 @@ def predict(sequence_input):
62
  raise gr.Error("模型未能加载或初始化失败,请检查后台日志。")
63
 
64
  if not sequence_input or not isinstance(sequence_input, str):
65
- raise gr.Error("请输入有效的生物序列。")
66
 
67
  cleaned_sequence = sequence_input.strip().upper()
68
 
69
  # --- 新增:在这里进行长度检查 ---
70
  EXPECTED_LENGTH = 49 # 定义期望的序列长度
71
  if len(cleaned_sequence) != EXPECTED_LENGTH:
72
- raise gr.Error(f"输入序列长度错误!模型要求序列长度必须为 {EXPECTED_LENGTH} 个字符,但您输入的长度为 {len(cleaned_sequence)}")
73
 
74
  sequence_list = [cleaned_sequence]
75
 
@@ -84,7 +84,7 @@ def predict(sequence_input):
84
 
85
  probabilities = torch.sigmoid(outputs).squeeze().cpu().numpy()
86
 
87
- labels = ["类别 A (a)", "类别 C (c)", "类别 M (m)", "类别 S (s)"]
88
  result = {label: float(prob) for label, prob in zip(labels, probabilities)}
89
 
90
  return result
@@ -96,14 +96,14 @@ demo = gr.Interface(
96
  fn=predict,
97
  inputs=gr.Textbox(
98
  lines=7,
99
- label="输入生物序列 (Input Sequence)",
100
  # 在占位符中提示长度要求
101
- placeholder="请在这里粘贴长度为 49 的序列..."
102
  ),
103
- outputs=gr.Label(num_top_classes=4, label="预测概率 (Prediction Probabilities)"),
104
- title="CAFN 模型部署:多标签序列分类器",
105
  # 在描述中明确强调长度要求
106
- description="输入一个生物序列,模型将预测它属于四个类别 (A, C, M, S) 中每一个的概率。\n\n**重要提示:本模型要求输入的序列长度必须为 49 个字符。**",
107
  # 提供一个或多个长度正确的示例
108
  examples=[
109
  [valid_example_sequence],
 
62
  raise gr.Error("模型未能加载或初始化失败,请检查后台日志。")
63
 
64
  if not sequence_input or not isinstance(sequence_input, str):
65
+ raise gr.Error("Please enter a valid biological sequence.")
66
 
67
  cleaned_sequence = sequence_input.strip().upper()
68
 
69
  # --- 新增:在这里进行长度检查 ---
70
  EXPECTED_LENGTH = 49 # 定义期望的序列长度
71
  if len(cleaned_sequence) != EXPECTED_LENGTH:
72
+ raise gr.Error(f"Wrong input sequence length! The model expects a sequence length of {EXPECTED_LENGTH} characters, but you entered a length of {len(cleaned_sequence)}.")
73
 
74
  sequence_list = [cleaned_sequence]
75
 
 
84
 
85
  probabilities = torch.sigmoid(outputs).squeeze().cpu().numpy()
86
 
87
+ labels = ["Acetyllysine (Kac)", "Crotonyllysine (Kcr)", "Methyllysine (Kme)", "Succinyllysine (Ksucc)"]
88
  result = {label: float(prob) for label, prob in zip(labels, probabilities)}
89
 
90
  return result
 
96
  fn=predict,
97
  inputs=gr.Textbox(
98
  lines=7,
99
+ label=" (Input Sequence)",
100
  # 在占位符中提示长度要求
101
+ placeholder="Please paste your 49-length sequence here, making sure your lysine is in the middle..."
102
  ),
103
+ outputs=gr.Label(num_top_classes=4, label=" (Prediction Probabilities)"),
104
+ title="CAFN Model Deployment: Multi-label Classifier for Lysine Modifications",
105
  # 在描述中明确强调长度要求
106
+ description="Given a biological sequence as input, the model predicts the probability of it belonging to each of the four classes (Kac, Kcr, Kme, Ksucc).\n\n**Important note: This model requires the input sequence to be 49 characters long.**",
107
  # 提供一个或多个长度正确的示例
108
  examples=[
109
  [valid_example_sequence],