Upload 4 files
Browse files- app.txt +21 -0
- requirements.txt +3 -0
- saved_model (2).pth +3 -0
- tokenizer (2).pkl +3 -0
app.txt
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import torch
|
3 |
+
import pickle
|
4 |
+
|
5 |
+
# Load the saved model on the CPU
|
6 |
+
model = torch.load('saved_model.pth', map_location=torch.device('cpu'))
|
7 |
+
|
8 |
+
# Load the saved tokenizer
|
9 |
+
with open('tokenizer.pkl', 'rb') as f:
|
10 |
+
tokenizer = pickle.load(f)
|
11 |
+
|
12 |
+
st.title("Text Classification Streamlit App")
|
13 |
+
|
14 |
+
input_text = st.text_input("Enter text:")
|
15 |
+
if st.button("Predict"):
|
16 |
+
with torch.no_grad():
|
17 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
18 |
+
logits = model(**inputs).logits
|
19 |
+
predicted_class = torch.argmax(logits, dim=1).item()
|
20 |
+
|
21 |
+
st.write(f"Predicted Class: {predicted_class}")
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|
3 |
+
|
saved_model (2).pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1f382c7389e4f5e8477ab48743fc6da57a5de01a1914c0a2ce242f082c3db0c1
|
3 |
+
size 510443484
|
tokenizer (2).pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6488d53ece4c6b9a687dfdda95a243ffafaea3a6399c1afac457b4beb1aa8a3f
|
3 |
+
size 2833452
|