Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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"
|
| 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 = ["
|
| 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="
|
| 100 |
# 在占位符中提示长度要求
|
| 101 |
-
placeholder="
|
| 102 |
),
|
| 103 |
-
outputs=gr.Label(num_top_classes=4, label="
|
| 104 |
-
title="CAFN
|
| 105 |
# 在描述中明确强调长度要求
|
| 106 |
-
description="
|
| 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],
|