Spaces:
Sleeping
Sleeping
Nazarshia2889
commited on
Commit
•
7bffddc
1
Parent(s):
818df16
update
Browse files
app.py
CHANGED
@@ -38,38 +38,39 @@ elif model_type == 'Linear B-Cell':
|
|
38 |
model = TFAutoModelForSequenceClassification.from_pretrained('bcell')
|
39 |
except:
|
40 |
st.warning("We're experiencing server issues. Please try again later!", icon="⚠️")
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
locations.append([peptide_name, output.logits.numpy()[0][0]])
|
50 |
|
51 |
-
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
|
73 |
-
|
|
|
|
|
74 |
# except InvalidArgumentError:
|
75 |
# st.warning("We're experiencing server issues. Please try again later!", icon="⚠️")
|
|
|
38 |
model = TFAutoModelForSequenceClassification.from_pretrained('bcell')
|
39 |
except:
|
40 |
st.warning("We're experiencing server issues. Please try again later!", icon="⚠️")
|
41 |
+
try:
|
42 |
+
# submit button
|
43 |
+
if st.button('Submit'):
|
44 |
+
locations = []
|
45 |
+
peptide_name = sequence
|
46 |
+
peptide = tokenizer(peptide_name, return_tensors="tf")
|
47 |
+
output = model(peptide)
|
48 |
+
locations.append([peptide_name, output.logits.numpy()[0][0]])
|
|
|
49 |
|
50 |
+
locations = pd.DataFrame(locations, columns = ['Peptide', 'Probability'])
|
51 |
|
52 |
+
# display table with sequence and probability as the headers
|
53 |
+
def color_survived(x: float): # x between 0 and 1
|
54 |
+
# red to green scale based on x
|
55 |
+
# 0 -> red
|
56 |
+
# 0.5 -> clear
|
57 |
+
# 1 -> green
|
58 |
|
59 |
+
# red
|
60 |
+
if x < threshold:
|
61 |
+
r = 179
|
62 |
+
g = 40
|
63 |
+
b = 2
|
64 |
+
# green
|
65 |
+
else:
|
66 |
+
r = 18
|
67 |
+
g = 150
|
68 |
+
b = 6
|
69 |
|
70 |
+
return f'background-color: rgb({r}, {g}, {b})'
|
71 |
|
72 |
+
st.table(locations.style.applymap(color_survived, subset=['Probability']))
|
73 |
+
except NameError:
|
74 |
+
st.warning("We're experiencing server issues. Please try again later!", icon="⚠️")
|
75 |
# except InvalidArgumentError:
|
76 |
# st.warning("We're experiencing server issues. Please try again later!", icon="⚠️")
|