Spaces:
Sleeping
Sleeping
Commit ·
f46ca7d
1
Parent(s): 326c338
Create model.py
Browse files
model.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'''
|
| 2 |
+
Phase 2 Graded Challenge 1
|
| 3 |
+
|
| 4 |
+
Nama : Achmad Dhani
|
| 5 |
+
|
| 6 |
+
Batch : HCK-009
|
| 7 |
+
|
| 8 |
+
Objective : Creating a page for emotion classification
|
| 9 |
+
'''
|
| 10 |
+
from functions import get_wordnet_pos, preprocess_text, text_model, prediction
|
| 11 |
+
import streamlit as st
|
| 12 |
+
import pandas as pd
|
| 13 |
+
import joblib
|
| 14 |
+
from PIL import Image
|
| 15 |
+
|
| 16 |
+
def run():
|
| 17 |
+
'''
|
| 18 |
+
This function is for running the page for predictions
|
| 19 |
+
'''
|
| 20 |
+
st.title('What are you feeling right now ?')
|
| 21 |
+
user_input = st.text_input(label='Enter some text',
|
| 22 |
+
value='default text',
|
| 23 |
+
max_chars=50,
|
| 24 |
+
key='text_input_key',
|
| 25 |
+
type='default',
|
| 26 |
+
help='Try not to think, and let your heart speak',
|
| 27 |
+
autocomplete=None,
|
| 28 |
+
on_change=None,
|
| 29 |
+
args=None,
|
| 30 |
+
kwargs=None,
|
| 31 |
+
placeholder='Please Type here...',
|
| 32 |
+
disabled=False,
|
| 33 |
+
label_visibility='visible')
|
| 34 |
+
|
| 35 |
+
st.write('You entered:', user_input)
|
| 36 |
+
|
| 37 |
+
# button
|
| 38 |
+
if st.button(label='Predict'):
|
| 39 |
+
X= preprocess_text(user_input)
|
| 40 |
+
prediction([X])
|
| 41 |
+
|