KarthikaRajagopal commited on
Commit
f6eeab1
·
verified ·
1 Parent(s): d244705

Upload recognition.py

Browse files
Files changed (1) hide show
  1. recognition.py +22 -0
recognition.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ from tensorflow.keras.models import load_model
3
+ from tensorflow.keras.preprocessing.text import one_hot
4
+ from tensorflow.keras.preprocessing.sequence import pad_sequences
5
+ import numpy as np
6
+ import pandas as pd
7
+
8
+ test_title = ["spark an inner revolution"]
9
+
10
+ labels = ["Reliable", "Unreliable"]
11
+
12
+ vocab_size = 5000
13
+ paddingLen = 20
14
+ oneHotRep = [one_hot(words, vocab_size) for words in test_title]
15
+ padded = pad_sequences(oneHotRep, truncating="post", padding="post", maxlen=paddingLen)
16
+
17
+ x = np.array(padded)
18
+
19
+ model = load_model("fake_news.h5")
20
+
21
+ pred = model.predict_classes(x)[0]
22
+ print(labels[int(pred)])