Spaces:
Sleeping
Sleeping
Akhil Koduri
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load pre-trained model and tokenizer from Hugging Face
|
5 |
+
model_name = "google-bert/bert-base-uncased"
|
6 |
+
pipe = pipeline("text-classification", model=model_name)
|
7 |
+
|
8 |
+
# Streamlit app
|
9 |
+
st.title("BERT Text Classification")
|
10 |
+
|
11 |
+
input_text = st.text_area("Enter text to classify")
|
12 |
+
|
13 |
+
if st.button("Classify"):
|
14 |
+
if input_text:
|
15 |
+
# Perform classification
|
16 |
+
result = pipe(input_text)
|
17 |
+
|
18 |
+
st.write(f"Predicted Class: {result[0]['label']}")
|
19 |
+
st.write(f"Confidence: {result[0]['score']:.4f}")
|
20 |
+
else:
|
21 |
+
st.write("Please enter some text to classify.")
|