Rishi-19 commited on
Commit
0acb963
·
1 Parent(s): eadf1f2

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +21 -0
  2. requirements.txt +3 -0
app.py 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
+