Zhonathon commited on
Commit
3c6e15d
1 Parent(s): ecb942d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -10
app.py CHANGED
@@ -1,18 +1,57 @@
 
 
1
  import streamlit as st
 
 
2
 
3
- count = 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- def storex(x):
6
- count = count + 1
7
- x = count + x
8
- return x
9
 
10
 
11
- x = st.text_input('1','2')
12
- x = int(x)
13
- x = storex(x)
14
- st.write(x)
15
- st.write(count)
16
 
17
 
18
 
 
1
+ import sys
2
+ import os
3
  import streamlit as st
4
+ import torch
5
+ from PIL import Image
6
 
7
+ st.title('Recommendation System V1')
8
+
9
+
10
+ def main():
11
+ if 'turn' not in st.session_state:
12
+ st.session_state['turn'] = 0
13
+ st.session_state['f_his_txt'] = [' ']
14
+ st.session_state['r_t'] = 0
15
+ st.session_state['g_t_id'] = 0
16
+
17
+ def interactive(r_t, input_text):
18
+ # input
19
+ st.session_state['turn'] += 1
20
+ st.session_state['r_t'] = int(r_t)
21
+ st.session_state['f_his_txt'].append(input_text)
22
+ st.write(st.session_state)
23
+
24
+ # update state
25
+ # f_his_txt = st.session_state['f_his_txt'].append(input_text)
26
+ g_t_id = st.session_state['g_t_id']
27
+ st.write(st.session_state)
28
+
29
+ def model(input_text, g_t_id, r_t):
30
+ if r_t == '':
31
+ r_t = 0
32
+ # to do model
33
+ g_t_id_next = g_t_id + 1
34
+ return g_t_id_next
35
+
36
+ def run_model(input_text, g_t_id, r_t):
37
+ g_t_id_next = model(input_text, g_t_id, r_t)
38
+ # st.image(Image.open(r'EPSOLON:\data\pictures\\' + str(g_t_id_next) + '.jpg').resize((224, 224)), caption=g_t_id_next, use_column_width='auto')
39
+ st.session_state['g_t_id'] = g_t_id_next
40
+ st.write(st.session_state)
41
+
42
+ # st.session_state['f_his_txt'] = f_his_txt
43
+ # st.button('Submit', on_click=run_model, args=(f_his_txt, g_t_id, r_t))
44
+
45
+ input_text = st.text_input('Input text', value='')
46
+ r_t = st.text_input('Input reward', value='0')
47
+ st.button('Interactive', on_click=interactive, args=(r_t, input_text))
48
+
49
+
50
+ if __name__ == "__main__":
51
+ main()
52
 
 
 
 
 
53
 
54
 
 
 
 
 
 
55
 
56
 
57