|
import gradio as gr |
|
import joblib |
|
|
|
|
|
model = joblib.load('random_forest_model_3labels2.joblib') |
|
encoder = joblib.load('label_encoder2.joblib') |
|
vectorizer = joblib.load('count_vectorizer2.joblib') |
|
|
|
def predict(input_text): |
|
|
|
vectorized_text = vectorizer.transform([input_text]) |
|
|
|
|
|
prediction = model.predict(vectorized_text) |
|
|
|
|
|
decoded_prediction = encoder.inverse_transform(prediction) |
|
|
|
|
|
return decoded_prediction[0] |
|
|
|
|
|
iface = gr.Interface(fn=predict, |
|
inputs=gr.Textbox(lines=2, placeholder="Enter Text Here..."), |
|
outputs="text", |
|
description="Detects hate speech in text. Outputs 'Neutral or Ambiguous', 'Not Hate', or 'Offensive or Hate Speech'.") |
|
|
|
|
|
iface.launch() |
|
|
|
|
|
""" |
|
import gradio as gr |
|
|
|
def greet(name): |
|
return "Hello " + name + "!!" |
|
|
|
iface = gr.Interface(fn=greet, inputs="text", outputs="text") |
|
iface.launch() |
|
""" |