Spaces:
Sleeping
Sleeping
Commit
·
e5dc65d
1
Parent(s):
ce9452e
feat: choose model
Browse files- app.py +34 -14
- src/__pycache__/modeling_t5.cpython-39.pyc +0 -0
app.py
CHANGED
@@ -130,29 +130,49 @@ def process_fasta(fasta_text):
|
|
130 |
|
131 |
|
132 |
# Create a Gradio interface
|
133 |
-
def
|
134 |
"""
|
135 |
Wrapper for Gradio to process the FASTA text.
|
136 |
"""
|
137 |
fasta_dict = process_fasta(fasta_text)
|
138 |
-
result = predictor.predict(fasta_dict)
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
|
148 |
interface = gr.Interface(
|
149 |
-
fn=
|
150 |
-
inputs=
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
),
|
153 |
-
outputs=gr.JSON(label="Prediction results"),
|
154 |
title="xBitterT5",
|
155 |
-
description=("
|
|
|
156 |
)
|
157 |
# Launch the Gradio app
|
158 |
interface.launch()
|
|
|
130 |
|
131 |
|
132 |
# Create a Gradio interface
|
133 |
+
def predict(choice, fasta_text):
|
134 |
"""
|
135 |
Wrapper for Gradio to process the FASTA text.
|
136 |
"""
|
137 |
fasta_dict = process_fasta(fasta_text)
|
138 |
+
result = predictor.predict(fasta_dict, model_type=choice)
|
139 |
+
result_df = pd.DataFrame(
|
140 |
+
{
|
141 |
+
"id": list(result.keys()),
|
142 |
+
"probability": [i[0] for i in result.values()],
|
143 |
+
"class": ["bitter" if i[1] == 1 else "non-bitter" for i in result.values()],
|
144 |
+
}
|
145 |
+
)
|
146 |
+
# text_result = f"ID\tClass\tProbability\n"
|
147 |
+
# for key, value in result.items():
|
148 |
+
# text_result += (
|
149 |
+
# f"{key}\t{'bitter' if value[1] == 1 else 'non-bitter'}\t{value[0]}\n"
|
150 |
+
# )
|
151 |
+
return result_df
|
152 |
|
153 |
|
154 |
interface = gr.Interface(
|
155 |
+
fn=predict,
|
156 |
+
inputs=[
|
157 |
+
gr.Dropdown(
|
158 |
+
choices=["xBitterT5-640", "xBitterT5-720"],
|
159 |
+
label="Select xBitterT5 variant",
|
160 |
+
value="xBitterT5-720",
|
161 |
+
),
|
162 |
+
gr.Textbox(
|
163 |
+
label="Enter peptide sequences in FASTA format",
|
164 |
+
lines=10,
|
165 |
+
placeholder=">id1\nVAPFPE\n>id2\nRRPP\n>id3\nGH\nid4\nGVDTK",
|
166 |
+
),
|
167 |
+
],
|
168 |
+
# outputs=gr.Textbox(label="Predictions", type="text"),
|
169 |
+
outputs=gr.Dataframe(
|
170 |
+
headers=["ID", "Class", "Probability"],
|
171 |
+
show_fullscreen_button=True,
|
172 |
),
|
|
|
173 |
title="xBitterT5",
|
174 |
+
description=("Prediction of bitter peptides using xBitterT5."),
|
175 |
+
flagging_mode="never",
|
176 |
)
|
177 |
# Launch the Gradio app
|
178 |
interface.launch()
|
src/__pycache__/modeling_t5.cpython-39.pyc
DELETED
Binary file (71.4 kB)
|
|