Балаганский Никита Николаевич commited on
Commit
92ec35a
1 Parent(s): b5ba927

add scatter tip

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -17,6 +17,8 @@ import pickle
17
 
18
  from plotly import graph_objects as go
19
 
 
 
20
  device = "cuda" if torch.cuda.is_available() else "cpu"
21
 
22
  ATTRIBUTE_MODELS = {
@@ -81,9 +83,9 @@ def main():
81
  layout = go.Layout({
82
  "yaxis": {"title": "CAIF step probability"},
83
  "xaxis": {"title": "Entropy threshold"},
84
- "template": "simple_white",
85
  })
86
- figure = go.Figure(data=[scatter], layout=layout)
87
  language = st.selectbox("Language", ("English", "Russian"))
88
  cls_model_name = st.selectbox(
89
  ATTRIBUTE_MODEL_LABEL[language],
@@ -106,8 +108,16 @@ def main():
106
  target_label_id = 1
107
  prompt = st.text_input(TEXT_PROMPT_LABEL[language], PROMPT_EXAMPLE[language])
108
  alpha = st.slider("Alpha", min_value=-10, max_value=10, step=1, value=0)
109
- st.plotly_chart(figure)
110
  entropy_threshold = st.slider("Entropy threshold", min_value=0., max_value=5., step=.1, value=2.)
 
 
 
 
 
 
 
 
 
111
  auth_token = os.environ.get('TOKEN') or True
112
  fp16 = st.checkbox("FP16", value=True)
113
  with st.spinner('Running inference...'):
 
17
 
18
  from plotly import graph_objects as go
19
 
20
+ import numpy as np
21
+
22
  device = "cuda" if torch.cuda.is_available() else "cpu"
23
 
24
  ATTRIBUTE_MODELS = {
 
83
  layout = go.Layout({
84
  "yaxis": {"title": "CAIF step probability"},
85
  "xaxis": {"title": "Entropy threshold"},
86
+ "template": "plotly_white",
87
  })
88
+
89
  language = st.selectbox("Language", ("English", "Russian"))
90
  cls_model_name = st.selectbox(
91
  ATTRIBUTE_MODEL_LABEL[language],
 
108
  target_label_id = 1
109
  prompt = st.text_input(TEXT_PROMPT_LABEL[language], PROMPT_EXAMPLE[language])
110
  alpha = st.slider("Alpha", min_value=-10, max_value=10, step=1, value=0)
 
111
  entropy_threshold = st.slider("Entropy threshold", min_value=0., max_value=5., step=.1, value=2.)
112
+ plot_idx = np.argmin(np.abs(entropy_threshold - x_s))
113
+ scatter_tip = go.Scatter({
114
+ "x": [x_s[plot_idx]],
115
+ "y": [y_s[plot_idx]],
116
+ "mode": "markers"
117
+ })
118
+ figure = go.Figure(data=[scatter, scatter_tip], layout=layout)
119
+ figure.update_layout(paper_bgcolor="#000000")
120
+ st.plotly_chart(figure)
121
  auth_token = os.environ.get('TOKEN') or True
122
  fp16 = st.checkbox("FP16", value=True)
123
  with st.spinner('Running inference...'):