sunwaee commited on
Commit
773ee0b
·
1 Parent(s): 5ac1eb0

maintenance

Browse files
Files changed (1) hide show
  1. app.py +30 -26
app.py CHANGED
@@ -85,30 +85,34 @@ st.set_page_config(layout="centered")
85
  st.title("Multiclass Emotion Classification")
86
  st.write("DeepMind Language Perceiver for Multiclass Emotion Classification (Eng). ")
87
 
88
- # Variables
89
- ids = {'perceiver-go-emotions': st.secrets['model_key']}
90
- labels = load_labels()
91
-
92
- # Download all models from drive
93
- download_models(ids)
94
-
95
- # Display labels
96
- st.markdown(f"__Labels:__ {', '.join(labels)}")
97
-
98
- # Model selection
99
- left, right = st.columns([4, 2])
100
- inputs = left.text_area('', max_chars=4096, value='This is a space about multiclass emotion classification. Write '
101
- 'something here to see what happens!')
102
- model_path = right.selectbox('', options=[k for k in ids], index=0, help='Model to use. ')
103
- split = right.checkbox('Split into sentences', value=True)
104
- model = load_model(model_path=f"model/{model_path}.pt")
105
- right.write(model.device)
106
-
107
- if split:
108
- if not inputs.isspace() and inputs != "":
109
- with st.spinner('Processing text... This may take a while.'):
110
- left.write(model(inputs_to_dataset(sent_tokenize(inputs)), batch_size=1))
111
  else:
112
- if not inputs.isspace() and inputs != "":
113
- with st.spinner('Processing text... This may take a while.'):
114
- left.write(model(inputs_to_dataset([inputs]), batch_size=1))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  st.title("Multiclass Emotion Classification")
86
  st.write("DeepMind Language Perceiver for Multiclass Emotion Classification (Eng). ")
87
 
88
+ maintenance = True
89
+ if maintenance:
90
+ print("Unavailable for now (file downloads limit). ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  else:
92
+ # Variables
93
+ ids = {'perceiver-go-emotions': st.secrets['model_key']}
94
+ labels = load_labels()
95
+
96
+ # Download all models from drive
97
+ download_models(ids)
98
+
99
+ # Display labels
100
+ st.markdown(f"__Labels:__ {', '.join(labels)}")
101
+
102
+ # Model selection
103
+ left, right = st.columns([4, 2])
104
+ inputs = left.text_area('', max_chars=4096, value='This is a space about multiclass emotion classification. Write '
105
+ 'something here to see what happens!')
106
+ model_path = right.selectbox('', options=[k for k in ids], index=0, help='Model to use. ')
107
+ split = right.checkbox('Split into sentences', value=True)
108
+ model = load_model(model_path=f"model/{model_path}.pt")
109
+ right.write(model.device)
110
+
111
+ if split:
112
+ if not inputs.isspace() and inputs != "":
113
+ with st.spinner('Processing text... This may take a while.'):
114
+ left.write(model(inputs_to_dataset(sent_tokenize(inputs)), batch_size=1))
115
+ else:
116
+ if not inputs.isspace() and inputs != "":
117
+ with st.spinner('Processing text... This may take a while.'):
118
+ left.write(model(inputs_to_dataset([inputs]), batch_size=1))