aftersix commited on
Commit
89315bc
·
1 Parent(s): 0c1cad2

initial commit

Browse files
Files changed (3) hide show
  1. app.py +142 -0
  2. icon-128x128.png +0 -0
  3. requirements.txt +7 -0
app.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from st_aggrid import AgGrid
3
+ import pandas as pd
4
+
5
+
6
+
7
+
8
+ #set page config
9
+ st.set_page_config(page_title='auditory skills resources', page_icon='icon-128x128.png')
10
+
11
+ #define session variables
12
+ if 'one' not in st.session_state:
13
+ st.session_state['one'] = 'value'
14
+
15
+ #main page content
16
+ with st.sidebar:
17
+ st.title('auditory skills')
18
+ st.header('powered by rascal')
19
+ st.markdown('''
20
+ ## About
21
+ This is a questionaire for parents to asses their child's auditory skills and recieve a custom list of resources that are customized for their child at their current stage of development. It is recommended that parents re-take the assessment every 4-6 weeks as their child progresses to ensure that the child is best able to build upon established auditory competencies.
22
+
23
+ ''')
24
+
25
+ st.write('Made with resources provided by the HATCH (Helping Adults Talk to Children) Lab. The HATCH lab is located at Idaho State University in Meridian, Idaho and seeks to ensure that adults have access to tools and resources to optimize the language of children through connection and engagement')
26
+
27
+ #for callback
28
+ def proc(key):
29
+ st.session_state['one'] = key
30
+ #st.write(st.session_state['one'])
31
+
32
+ def main():
33
+ #st.markdown('hello')
34
+ if 'current_view' not in st.session_state:
35
+ st.session_state['current_view'] = 'Grid'
36
+
37
+ if 'current_step' not in st.session_state:
38
+ st.session_state['current_step'] = 1
39
+
40
+
41
+ def set_page_view(page):
42
+ st.session_state['current_view'] = page
43
+ st.session_state['current_step'] = 1
44
+
45
+ def set_form_step(action,step=None):
46
+ if action == 'Next':
47
+ st.session_state['current_step'] = st.session_state['current_step'] + 1
48
+ if action == 'Back':
49
+ st.session_state['current_step'] = st.session_state['current_step'] - 1
50
+ if action == 'Jump':
51
+ st.session_state['current_step'] = step
52
+
53
+
54
+ ##### wizard functions ####
55
+ def wizard_form_header():
56
+ sf_header_cols = st.columns([1,1.75,1])
57
+
58
+ with sf_header_cols[1]:
59
+ st.subheader('Auditory Stages')
60
+
61
+ # determines button color which should be red when user is on that given step
62
+ wh_type = 'primary' if st.session_state['current_step'] == 1 else 'secondary'
63
+ ff_type = 'primary' if st.session_state['current_step'] == 2 else 'secondary'
64
+ lo_type = 'primary' if st.session_state['current_step'] == 3 else 'secondary'
65
+ sf_type = 'primary' if st.session_state['current_step'] == 4 else 'secondary'
66
+
67
+ step_cols = st.columns([.5,.85,.85,.85,.85,.5])
68
+ step_cols[1].button('Does your child respond to a familiar voice?',on_click=set_form_step,args=['Jump',1])
69
+ step_cols[2].button('Does your child listen to somebody speaking?',on_click=set_form_step,args=['Jump',2])
70
+ step_cols[3].button('When somebody is speaking, does your child turn his/her head towards the speaker?',on_click=set_form_step,args=['Jump',3])
71
+ step_cols[4].button('Is your child interested in toys producing sounds or music?',on_click=set_form_step,args=['Jump',4])
72
+
73
+ ### Replace Wizard Form Body with this ###
74
+ def wizard_form_body():
75
+ if st.session_state['current_step'] == 1:
76
+ with st.form("question-1"):
77
+ st.write("session state is one")
78
+ #st.text_input("enter text",on_change=proc,key='key',args=("Brightness",))
79
+ textone = st.text_input("enter text")
80
+ submitted = st.form_submit_button("Submit")
81
+ if submitted:
82
+ #sequence = textone
83
+ #output = classifier(sequence, sequence_labels)
84
+ st.session_state['one'] = textone
85
+
86
+
87
+ def wizard_form_footer():
88
+ form_footer_container = st.empty()
89
+ with form_footer_container.container():
90
+
91
+ disable_back_button = True if st.session_state['current_step'] == 1 else False
92
+ disable_next_button = True if st.session_state['current_step'] == 4 else False
93
+
94
+ form_footer_cols = st.columns([5,1,1,1.75])
95
+
96
+ form_footer_cols[0].button('Cancel',on_click=set_page_view,args=['Grid'])
97
+ form_footer_cols[1].button('Back',on_click=set_form_step,args=['Back'],disabled=disable_back_button)
98
+ form_footer_cols[2].button('Next',on_click=set_form_step,args=['Next'],disabled=disable_next_button)
99
+
100
+
101
+
102
+ ### Replace Render Wizard View With This ###
103
+ def render_wizard_view():
104
+ with st.expander('',expanded=True):
105
+ wizard_form_header()
106
+ st.markdown('---')
107
+ wizard_form_body()
108
+ st.markdown('---')
109
+ wizard_form_footer()
110
+
111
+
112
+
113
+ render_wizard_view()
114
+ st.subheader('Your resources')
115
+ st.markdown('list here...')
116
+ st.markdown(st.session_state['one'])
117
+ #sequence = "My kid will look at me when the tv is on but I'm in the other room"
118
+ #sequence_labels=["Detection", "discrimination", "Identification", "Classification"]
119
+
120
+ #output = classifier(sequence, sequence_labels)
121
+ #st.markdown(output)
122
+ with st.form("get-results"):
123
+ st.write("get results form")
124
+ submitted = st.form_submit_button("Get Results")
125
+ if submitted:
126
+ #load everything
127
+ from transformers import pipeline
128
+
129
+ #define classifier for zero shot classification
130
+ classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
131
+ #define sequence
132
+ sequence_labels=["Detection", "discrimination", "Identification", "Classification"]
133
+ sequence = st.session_state['one']
134
+ output = classifier(sequence, sequence_labels)
135
+ st.markdown(output)
136
+
137
+
138
+
139
+
140
+ #run main
141
+ if __name__ == '__main__':
142
+ main()
icon-128x128.png ADDED
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+
2
+ streamlit
3
+ streamlit-aggrid
4
+ streamlit-lottie
5
+ altair==4.0
6
+ transformers
7
+ tensorflow-cpu