Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -4,22 +4,28 @@ from transformers import TFAUTOModelForSequenceClassification
|
|
4 |
import tensorflow as tf
|
5 |
|
6 |
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|
7 |
-
model = TFAUTOModelForSequenceClassification.from_pretrained('')
|
8 |
|
9 |
|
10 |
|
11 |
text = st.text_area('Your StackOverFlow Question')
|
12 |
|
13 |
-
def
|
14 |
-
inputs = tokenizer(text,
|
15 |
add_special_tokens = True,
|
16 |
padding='max_length',
|
17 |
truncation=True,
|
18 |
max_length=SEQ_LEN,
|
19 |
return_token_type_ids=False,
|
20 |
return_tensors = 'tf')
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
return
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
4 |
import tensorflow as tf
|
5 |
|
6 |
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|
7 |
+
model = TFAUTOModelForSequenceClassification.from_pretrained('./')
|
8 |
|
9 |
|
10 |
|
11 |
text = st.text_area('Your StackOverFlow Question')
|
12 |
|
13 |
+
def preprocess_predict(text):
|
14 |
+
inputs = tokenizer.encode(text,
|
15 |
add_special_tokens = True,
|
16 |
padding='max_length',
|
17 |
truncation=True,
|
18 |
max_length=SEQ_LEN,
|
19 |
return_token_type_ids=False,
|
20 |
return_tensors = 'tf')
|
21 |
+
|
22 |
+
preds = model.predict(imputs)
|
23 |
+
probabilities = tf.nn.softmax(preds['logits'])
|
24 |
+
class_preds = np.argmax(probabilities,axis=1)
|
25 |
|
26 |
+
return class_preds
|
27 |
|
28 |
+
|
29 |
+
if text =True
|
30 |
+
out = preprocess_predict(text)
|
31 |
+
st.json(out)
|