Spaces:
Sleeping
Sleeping
File size: 1,318 Bytes
1b05faa d992880 d47887e 1b05faa ec9cc94 1b05faa fcc813b 1b05faa fcc813b ec9cc94 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import streamlit as st
import pickle
from sentence_transformers import SentenceTransformer
import pandas as pd
import numpy as np
lr_model_loaded = pickle.load(open('./models/lr_model.pkl', 'rb'))
scaler_loaded = pickle.load(open('./models/scaler.pkl', 'rb'))
stmodel = SentenceTransformer("all-MiniLM-L6-v2")
def predict(context):
r = stmodel.encode(context)
y_pred = scaler_loaded.transform([r])
#print(y_pred)
result = lr_model_loaded.predict(y_pred)
return 'บทวิเคราะห์' if result[0] == 1 else 'ไม่ใช่บทวิเคราะห์'
st.write("# News Analyzer\n")
st.write("เป็น Model สำหรับตรวจสอบว่าข่าวนี้เป็นข่าวประเภทบทวิเคราะห์หรือไม่")
context = st.text_area('สามารถวางเนื้อหาข่าวเพื่อตรวจสอบได้ที่นี่',height=300)
if context:
with st.spinner(text="In progress..."):
r = predict(context)
if r == "บทวิเคราะห์":
st.write("## เนื้อหานี้เป็นบทวิเคราะห์")
else:
st.write("## เนื้อหานี้ไม่ใช่บทวิเคราะห์")
|