Orcun2 commited on
Commit
6a5e8a3
1 Parent(s): 3f47019

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -16
app.py CHANGED
@@ -5,25 +5,13 @@ import tensorflow as tf
5
  import numpy as np
6
  from tensorflow.keras.layers import TextVectorization
7
 
8
- df = pd.read_csv(os.path.join('train.csv'))
9
- X = df['comment_text']
 
 
10
 
11
  columns = ['toxic', 'severe_toxic', 'obscene', 'threat', 'insult', 'identity_hate']
12
 
13
- # # load numpy array from npy file
14
- # from numpy import load
15
- # # load array
16
- # xValues = np.load('forVectorizer.npy', allow_pickle=True)
17
-
18
- # SET THE VECTORIZER
19
- #set max features
20
- MAX_FEATURES = 200000
21
- vectorizer = TextVectorization(max_tokens=MAX_FEATURES,
22
- output_sequence_length=1800,
23
- output_mode='int')
24
-
25
- vectorizer.adapt(X.values)
26
-
27
  model = tf.keras.models.load_model('toxicity.h5')
28
 
29
  def score_comment(comment):
 
5
  import numpy as np
6
  from tensorflow.keras.layers import TextVectorization
7
 
8
+ # Load.
9
+ filepath = "tmp-model"
10
+ loaded_model = tf.keras.models.load_model(filepath)
11
+ vectorizer = loaded_model.layers[0]
12
 
13
  columns = ['toxic', 'severe_toxic', 'obscene', 'threat', 'insult', 'identity_hate']
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  model = tf.keras.models.load_model('toxicity.h5')
16
 
17
  def score_comment(comment):