Tho Tran commited on
Commit
f69297f
1 Parent(s): 3899d48

update and fixes

Browse files
Files changed (2) hide show
  1. app.py +5 -2
  2. requirements.txt +2 -0
app.py CHANGED
@@ -3,8 +3,9 @@ from transformers import TFAutoModelForSequenceClassification
3
  from transformers import AutoTokenizer, AutoConfig
4
  import numpy as np
5
  from scipy.special import softmax
6
-
7
  # Preprocess text (username and link placeholders)
 
8
  def preprocess(text):
9
  new_text = []
10
  for t in text.split(" "):
@@ -21,14 +22,16 @@ config = AutoConfig.from_pretrained(MODEL)
21
  # PT
22
  model = AutoModelForSequenceClassification.from_pretrained(MODEL)
23
  model.save_pretrained(MODEL)
 
24
 
25
- text = "Good night 😊"
26
  text = preprocess(text)
27
  encoded_input = tokenizer(text, return_tensors='pt')
28
  output = model(**encoded_input)
29
  scores = output[0][0].detach().numpy()
30
  scores = softmax(scores)
31
 
 
32
  # Print labels and scores
33
  ranking = np.argsort(scores)
34
  ranking = ranking[::-1]
 
3
  from transformers import AutoTokenizer, AutoConfig
4
  import numpy as np
5
  from scipy.special import softmax
6
+ import streamlit as st
7
  # Preprocess text (username and link placeholders)
8
+ st.title("Tho Tran Milestone2")
9
  def preprocess(text):
10
  new_text = []
11
  for t in text.split(" "):
 
22
  # PT
23
  model = AutoModelForSequenceClassification.from_pretrained(MODEL)
24
  model.save_pretrained(MODEL)
25
+ tokenizer.save_pretrained(MODEL)
26
 
27
+ text = st.text_input("Enter text here:","I love you")
28
  text = preprocess(text)
29
  encoded_input = tokenizer(text, return_tensors='pt')
30
  output = model(**encoded_input)
31
  scores = output[0][0].detach().numpy()
32
  scores = softmax(scores)
33
 
34
+
35
  # Print labels and scores
36
  ranking = np.argsort(scores)
37
  ranking = ranking[::-1]
requirements.txt CHANGED
@@ -2,3 +2,5 @@ torch
2
  numpy
3
  scipy
4
  transformers
 
 
 
2
  numpy
3
  scipy
4
  transformers
5
+ sentencepiece
6
+ streamlit