Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
# Load your serialized objects
|
| 4 |
model = joblib.load('random_forest_model_3labels2.joblib')
|
|
@@ -14,7 +15,7 @@ def predict(input_text):
|
|
| 14 |
prediction = model.predict(vectorized_text)
|
| 15 |
|
| 16 |
# If your model's output needs to be decoded (optional)
|
| 17 |
-
|
| 18 |
|
| 19 |
# Return the prediction (you might want to convert it into a more readable form)
|
| 20 |
return prediction[0] # Modify this according to your needs
|
|
@@ -23,7 +24,7 @@ def predict(input_text):
|
|
| 23 |
iface = gr.Interface(fn=predict,
|
| 24 |
inputs=gr.Textbox(lines=2, placeholder="Enter Text Here..."),
|
| 25 |
outputs="text",
|
| 26 |
-
description="
|
| 27 |
|
| 28 |
# Launch the app
|
| 29 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import joblib
|
| 3 |
|
| 4 |
# Load your serialized objects
|
| 5 |
model = joblib.load('random_forest_model_3labels2.joblib')
|
|
|
|
| 15 |
prediction = model.predict(vectorized_text)
|
| 16 |
|
| 17 |
# If your model's output needs to be decoded (optional)
|
| 18 |
+
decoded_prediction = encoder.inverse_transform(prediction)
|
| 19 |
|
| 20 |
# Return the prediction (you might want to convert it into a more readable form)
|
| 21 |
return prediction[0] # Modify this according to your needs
|
|
|
|
| 24 |
iface = gr.Interface(fn=predict,
|
| 25 |
inputs=gr.Textbox(lines=2, placeholder="Enter Text Here..."),
|
| 26 |
outputs="text",
|
| 27 |
+
description="Detects hate speech in text. Outputs 'Neutral or Ambiguous', 'Not Hate', or 'Offensive or Hate Speech'.")
|
| 28 |
|
| 29 |
# Launch the app
|
| 30 |
iface.launch()
|