Spaces:
Sleeping
Sleeping
menimeni123
commited on
Commit
·
5670da9
1
Parent(s):
4b0f8ea
latest
Browse files- .DS_Store +0 -0
- app.py +5 -15
- model.joblib +0 -0
- vectorizer.joblib +0 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
app.py
CHANGED
@@ -1,30 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
import joblib
|
3 |
-
import re
|
4 |
|
5 |
-
# Load the
|
6 |
-
|
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 |
-
|
18 |
-
|
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
|
28 |
|
29 |
# Launch the interface
|
30 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import joblib
|
|
|
3 |
|
4 |
+
# Load the pipeline (which includes both the vectorizer and the classifier)
|
5 |
+
pipeline = joblib.load('gibberish_detector_pipeline.joblib')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Prediction function
|
8 |
def predict(text):
|
9 |
+
prediction = pipeline.predict([text])[0]
|
10 |
+
return "Gibberish" if prediction == 1 else "Good English"
|
|
|
|
|
11 |
|
12 |
# Create a Gradio interface
|
13 |
iface = gr.Interface(fn=predict,
|
14 |
inputs="text",
|
15 |
outputs="text",
|
16 |
title="Gibberish Detector",
|
17 |
+
description="Enter a string to check if it's gibberish or good English.")
|
18 |
|
19 |
# Launch the interface
|
20 |
iface.launch()
|
model.joblib
DELETED
Binary file (75.2 kB)
|
|
vectorizer.joblib
DELETED
Binary file (199 kB)
|
|