File size: 805 Bytes
d5b85a1
 
 
 
 
 
 
 
919b967
381295f
d5b85a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr
import joblib
from sklearn.feature_extraction.text import CountVectorizer

# Install the required libraries if you don't have them already
# !pip install gradio joblib scikit-learn

# Load the saved model and vectorizer
clf = joblib.load("./resturants.pkl",'rb')
vectorizer = joblib.load("./vectorizer.joblib")

# Define the prediction function
def predict_text(text):
    # Vectorize the input text using the loaded vectorizer
    text_vectorized = vectorizer.transform([text])

    # Make the prediction using the loaded model
    predicted_output = clf.predict(text_vectorized)

    # Return the predicted output (0 or 1)
    return predicted_output[0]

# Create a Gradio interface
iface = gr.Interface(
    fn=predict_text,
    inputs="text",
    outputs=["text"]
)

iface.launch()