menimeni123 commited on
Commit
ef570d8
·
1 Parent(s): 80508e8
Files changed (3) hide show
  1. app.py +30 -0
  2. model.joblib +0 -0
  3. vectorizer.joblib +0 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import re
4
+
5
+ # Load the model and vectorizer
6
+ model = joblib.load('model.joblib')
7
+ vectorizer = joblib.load('vectorizer.joblib')
8
+
9
+ # Preprocess function
10
+ def preprocess(text):
11
+ text = text.lower()
12
+ text = re.sub(r'\W+', ' ', text)
13
+ return text
14
+
15
+ # Prediction function
16
+ def predict(text):
17
+ text = preprocess(text)
18
+ X = vectorizer.transform([text])
19
+ prediction = model.predict(X)[0]
20
+ return "Gibberish" if prediction == 1 else "Clean"
21
+
22
+ # Create a Gradio interface
23
+ iface = gr.Interface(fn=predict,
24
+ inputs="text",
25
+ outputs="text",
26
+ title="Gibberish Detector",
27
+ description="Enter a string to check if it's gibberish or clean.")
28
+
29
+ # Launch the interface
30
+ iface.launch()
model.joblib ADDED
Binary file (75.2 kB). View file
 
vectorizer.joblib ADDED
Binary file (199 kB). View file