Spaces:
Runtime error
Runtime error
Commit
·
af36e0b
1
Parent(s):
4925e24
uploaded app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
from transformers import AutoTokenizer as AT, AutoModelForSequenceClassification as AFSC
|
| 4 |
+
|
| 5 |
+
modName = "madhurjindal/autonlp-Gibberish-Detector-492513457" # Gibberish Detection Model from HuggingFace
|
| 6 |
+
|
| 7 |
+
mod = AFSC.from_pretrained(modName)
|
| 8 |
+
TKR = AT.from_pretrained(modName)
|
| 9 |
+
|
| 10 |
+
st.title("Gibberish Detector")
|
| 11 |
+
|
| 12 |
+
user_input = st.text_input("Enter some words", "[Pre-populted Text]: pasghetti")
|
| 13 |
+
st.markdown("Input was: ", user_input)
|
| 14 |
+
|
| 15 |
+
classifier = pipeline("sentiment-analysis", model=mod, tokenizer=TKR)
|
| 16 |
+
# result = classifier(["This is a sample text made by Sean Ramirez.", "This is another sample text."]) # leftover from initial testing
|
| 17 |
+
|
| 18 |
+
if user_input is not None:
|
| 19 |
+
col = st.columns(1)
|
| 20 |
+
predicts = pipeline("sentiment-analysis", model=mod, tokenizer=TKR)
|
| 21 |
+
|
| 22 |
+
col.header("Probabilities")
|
| 23 |
+
for p in predicts:
|
| 24 |
+
col.subheader(f"{ p['label']}: { round(p['score'] * 100, 1)}%")
|