Spaces:
Runtime error
Runtime error
wnagleiofficial
commited on
Commit
·
45b7faf
1
Parent(s):
9d54723
fix bugs
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ def classifier(peptide_seq):
|
|
| 10 |
for record in SeqIO.parse(handle, 'fasta'):
|
| 11 |
data.append((record.id, str(record.seq)))
|
| 12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 13 |
-
neuropeptide_pred = predict(data, '
|
| 14 |
return neuropeptide_pred
|
| 15 |
# {peptide_id:[Type:int(1->neuropeptide,0->non-neuropeptide), attention score:nd.array]}
|
| 16 |
|
|
@@ -20,7 +20,7 @@ def batch_classifier(file, cutoff):
|
|
| 20 |
for record in SeqIO.parse(file.name, 'fasta'):
|
| 21 |
data.append((record.id, str(record.seq)))
|
| 22 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 23 |
-
neuropeptide_pred = batch_predict(data, cutoff, '
|
| 24 |
return neuropeptide_pred
|
| 25 |
|
| 26 |
with gr.Blocks() as demo:
|
|
@@ -39,7 +39,7 @@ with gr.Blocks() as demo:
|
|
| 39 |
single_cutoff = gr.Slider(0, 1, step=0.1, value=0.5, interactive=True, label="Threshold")
|
| 40 |
text_button = gr.Button("Submit")
|
| 41 |
with gr.Column(scale=2):
|
| 42 |
-
gr.Markdown("
|
| 43 |
text_output = gr.outputs.Label(num_top_classes=2, label='Output')
|
| 44 |
with gr.Tab("Batch Model"):
|
| 45 |
with gr.Row():
|
|
@@ -56,7 +56,7 @@ with gr.Blocks() as demo:
|
|
| 56 |
image_button = gr.Button("Submit")
|
| 57 |
with gr.Column():
|
| 58 |
# gr.Markdown(" ### Flip text or image files using this demo.")
|
| 59 |
-
gr.Markdown("
|
| 60 |
frame_output = gr.DataFrame(headers=["Sequence Id", "Sequence", "Probability of neuropeptides", "Neuropeptide"],
|
| 61 |
datatype=["str", "str", "str", 'str'],)
|
| 62 |
|
|
|
|
| 10 |
for record in SeqIO.parse(handle, 'fasta'):
|
| 11 |
data.append((record.id, str(record.seq)))
|
| 12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 13 |
+
neuropeptide_pred = predict(data, './model.pth', device)
|
| 14 |
return neuropeptide_pred
|
| 15 |
# {peptide_id:[Type:int(1->neuropeptide,0->non-neuropeptide), attention score:nd.array]}
|
| 16 |
|
|
|
|
| 20 |
for record in SeqIO.parse(file.name, 'fasta'):
|
| 21 |
data.append((record.id, str(record.seq)))
|
| 22 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 23 |
+
neuropeptide_pred = batch_predict(data, cutoff, './model.pth', device)
|
| 24 |
return neuropeptide_pred
|
| 25 |
|
| 26 |
with gr.Blocks() as demo:
|
|
|
|
| 39 |
single_cutoff = gr.Slider(0, 1, step=0.1, value=0.5, interactive=True, label="Threshold")
|
| 40 |
text_button = gr.Button("Submit")
|
| 41 |
with gr.Column(scale=2):
|
| 42 |
+
gr.Markdown("Note: the larger the probability score of neuropeptide output, the more likely it is to belong to neuropeptide. Generally, result greater than the threshold (default:0.5) is considered to belong to neuropeptides.")
|
| 43 |
text_output = gr.outputs.Label(num_top_classes=2, label='Output')
|
| 44 |
with gr.Tab("Batch Model"):
|
| 45 |
with gr.Row():
|
|
|
|
| 56 |
image_button = gr.Button("Submit")
|
| 57 |
with gr.Column():
|
| 58 |
# gr.Markdown(" ### Flip text or image files using this demo.")
|
| 59 |
+
gr.Markdown("Note: the larger the probability score of neuropeptide output, the more likely it is to belong to neuropeptide. Generally, result greater than the threshold (default:0.5) is considered to belong to neuropeptides.")
|
| 60 |
frame_output = gr.DataFrame(headers=["Sequence Id", "Sequence", "Probability of neuropeptides", "Neuropeptide"],
|
| 61 |
datatype=["str", "str", "str", 'str'],)
|
| 62 |
|