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