File size: 718 Bytes
956ca11
8a6d1ee
 
956ca11
8a6d1ee
4aeab18
8a6d1ee
4aeab18
8a6d1ee
956ca11
d35b39f
8a6d1ee
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
import mediapipe as mp
#from transformers import pipeline

base_options = mp.tasks.BaseOptions(model_asset_path="classifier.tflite")
options      = mp.tasks.text.TextClassifierOptions(base_options=base_options)
with mp.tasks.text.TextClassifier.create_from_options(options) as classifier:
    text   = st.text_area("enter some text")
    result = classifier.classify(text)

    category = result.classifications[0].categories[0]
    if text and category:
        st.json({
            "name": category.category_name,
            "score": category.score
        })

#pipe = pipeline("sentiment-analysis")
#text = st.text_area("enter some text")

#if text:
#    out = pipe(text)
#    st.json(out)