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()