terapyon commited on
Commit
720d81f
·
1 Parent(s): c39349e

判定部分のUIモデルから呼び出すようにし、関連パッケージを設定

Browse files
Files changed (2) hide show
  1. app.py +11 -9
  2. requirements.txt +10 -0
app.py CHANGED
@@ -1,8 +1,6 @@
1
- import random
2
-
3
- import numpy as np
4
  import streamlit as st
5
 
 
6
  from visualization import heatmap, html_hext
7
 
8
  ID2CAT = {
@@ -35,13 +33,17 @@ if st.button("判定", key="run"):
35
  else:
36
  st.markdown(attention_text)
37
  st.divider()
38
- random_id = random.randint(0, 1) # TODO: make dummy data
39
- st.markdown(f"判定結果: **{ID2CAT[random_id]}**")
40
- if random_id == 1:
41
- rng = np.random.default_rng() # TODO: make dummy data
42
- html_hext_result = html_hext(((f"単語{i}", rng.random()) for i in range(7))) # TODO: make dummy data
 
 
 
43
  st.markdown(html_hext_result, unsafe_allow_html=True)
44
- data = rng.random((10, 1)).reshape(-1, 1) # TODO: make dummy data
 
45
  st.plotly_chart(heatmap(data), use_container_width=True)
46
 
47
 
 
 
 
 
1
  import streamlit as st
2
 
3
+ from inference import classify_ma, get_word_attn, infer_topic
4
  from visualization import heatmap, html_hext
5
 
6
  ID2CAT = {
 
33
  else:
34
  st.markdown(attention_text)
35
  st.divider()
36
+
37
+ pred_class, input_ids, attention_list = classify_ma(user_input)
38
+ st.markdown(f"判定結果: **{ID2CAT[pred_class]}**")
39
+ if pred_class == 1:
40
+ topic_dist, ll = infer_topic(user_input)
41
+
42
+ words_atten = get_word_attn(input_ids, attention_list)
43
+ html_hext_result = html_hext(((word, attn) for word, attn in words_atten))
44
  st.markdown(html_hext_result, unsafe_allow_html=True)
45
+
46
+ data = topic_dist.reshape(-1, 1)
47
  st.plotly_chart(heatmap(data), use_container_width=True)
48
 
49
 
requirements.txt CHANGED
@@ -2,3 +2,13 @@ streamlit
2
  numpy
3
  pandas
4
  plotly
 
 
 
 
 
 
 
 
 
 
 
2
  numpy
3
  pandas
4
  plotly
5
+ transformers
6
+ scipy
7
+ torch
8
+ fugashi
9
+ unidic-lite
10
+ sudachipy
11
+ sudachidict_full
12
+ sudachidict_core
13
+ tomotopy
14
+