Spaces:
Running
Running
yinuozhang
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModel, AutoConfig
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("facebook/esm2_t33_650M_UR50D")
|
6 |
+
config = AutoConfig.from_pretrained("ChatterjeeLab/MetaLATTE")
|
7 |
+
model = AutoModel.from_pretrained("ChatterjeeLab/MetaLATTE", config=config)
|
8 |
+
|
9 |
+
def predict(sequence):
|
10 |
+
inputs = tokenizer(sequence, return_tensors="pt")
|
11 |
+
raw_probs, predictions = model(**inputs)
|
12 |
+
|
13 |
+
id2label = config.id2label
|
14 |
+
results = {}
|
15 |
+
for i, pred in enumerate(predictions[0]):
|
16 |
+
metal = id2label[i]
|
17 |
+
probability = raw_probs[0][i].item()
|
18 |
+
results[metal] = '✓' if pred == 1 else ''
|
19 |
+
|
20 |
+
df = pd.DataFrame([results])
|
21 |
+
return df
|
22 |
+
|
23 |
+
iface = gr.Interface(
|
24 |
+
fn=predict,
|
25 |
+
inputs=gr.Textbox(lines=3, placeholder="Enter protein sequence here..."),
|
26 |
+
outputs=gr.Dataframe(headers=list(config.id2label.values())),
|
27 |
+
title="MetaLATTE: Metal Binding Prediction",
|
28 |
+
description="Enter a protein sequence to predict its metal binding properties."
|
29 |
+
)
|
30 |
+
|
31 |
+
iface.launch()
|