Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,3 @@
|
|
| 1 |
-
import numpy as np
|
| 2 |
-
import pandas as pd
|
| 3 |
-
import matplotlib.pyplot as plt
|
| 4 |
-
from matplotlib import style
|
| 5 |
-
import seaborn as sns
|
| 6 |
-
import tensorflow as tf
|
| 7 |
-
from transformers import BertTokenizer
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
from sklearn.model_selection import train_test_split
|
| 12 |
-
from sklearn.preprocessing import LabelEncoder
|
| 13 |
-
from keras.utils import to_categorical
|
| 14 |
-
from sklearn import preprocessing
|
| 15 |
-
import sklearn
|
| 16 |
-
from sklearn.metrics import confusion_matrix
|
| 17 |
-
|
| 18 |
from transformers import AutoModelForSequenceClassification
|
| 19 |
from transformers import AutoTokenizer, AutoConfig
|
| 20 |
import numpy as np
|
|
@@ -40,7 +23,7 @@ tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
|
| 40 |
config = AutoConfig.from_pretrained(MODEL)
|
| 41 |
|
| 42 |
# create classifier function
|
| 43 |
-
def
|
| 44 |
text = preprocess(text)
|
| 45 |
encoded_input = tokenizer(text, return_tensors='pt')
|
| 46 |
output = model(**encoded_input)
|
|
@@ -69,7 +52,7 @@ article = """
|
|
| 69 |
- Click clear button to refresh text
|
| 70 |
"""
|
| 71 |
|
| 72 |
-
gr.Interface(,
|
| 73 |
'text',
|
| 74 |
'label',
|
| 75 |
title = title,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from transformers import AutoModelForSequenceClassification
|
| 2 |
from transformers import AutoTokenizer, AutoConfig
|
| 3 |
import numpy as np
|
|
|
|
| 23 |
config = AutoConfig.from_pretrained(MODEL)
|
| 24 |
|
| 25 |
# create classifier function
|
| 26 |
+
def classify_compliant(text):
|
| 27 |
text = preprocess(text)
|
| 28 |
encoded_input = tokenizer(text, return_tensors='pt')
|
| 29 |
output = model(**encoded_input)
|
|
|
|
| 52 |
- Click clear button to refresh text
|
| 53 |
"""
|
| 54 |
|
| 55 |
+
gr.Interface(classify_compliant,
|
| 56 |
'text',
|
| 57 |
'label',
|
| 58 |
title = title,
|