File size: 1,595 Bytes
840e37c bc56514 840e37c 2032430 bc56514 54299e5 bc56514 9364099 bc56514 9364099 bc56514 a9706bf 2032430 |
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 31 32 33 34 35 36 37 38 39 40 |
import gradio as gr
from train_abuse_model import (
run_training,
evaluate_saved_model,
push_model_to_hub
)
from predict_pipeline import run_prediction_pipeline
with gr.Blocks() as demo:
gr.Markdown("## ๐ง Abuse Detection App")
gr.Markdown("โ ๏ธ Keep this tab open while training or evaluating.")
with gr.Tab("๐งช Train / Evaluate"):
with gr.Row():
start_btn = gr.Button("๐ Start Training")
eval_btn = gr.Button("๐ Evaluate Trained Model")
push_btn = gr.Button("๐ค Push Model to Hub")
output_box = gr.Textbox(label="Logs", lines=25, interactive=False)
start_btn.click(fn=run_training, outputs=output_box)
eval_btn.click(fn=evaluate_saved_model, outputs=output_box)
push_btn.click(fn=push_model_to_hub, outputs=output_box)
with gr.Tab("๐ฎ Abuse Detection"):
desc_input = gr.Textbox(label="๐ Relationship Description", lines=5, placeholder="Write a relationship story here...")
chat_upload = gr.File(label="๐ Optional: WhatsApp Chat ZIP (.zip)", file_types=[".zip"])
predict_btn = gr.Button("Run Prediction")
enriched_output = gr.Textbox(label="๐ Enriched Input (Used for Prediction)", lines=8, interactive=False)
label_output = gr.Textbox(label="๐ท๏ธ Predicted Labels", lines=2, interactive=False)
predict_btn.click(
fn=run_prediction_pipeline,
inputs=[desc_input, chat_upload],
outputs=[enriched_output, label_output]
)
if __name__ == "__main__":
demo.launch()
|