Spaces:
Sleeping

File size: 888 Bytes
de4c752
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# app.py  → Gradio frontend

import gradio as gr
from backend_core import predict_from_text

def ui_predict(text):
    response = predict_from_text(text)
    if isinstance(response, dict):
        if "error" in response:
            return f"ERROR: {response['error']}"
        if "prediction" in response:
            return response["prediction"]
    return str(response)

with gr.Blocks() as demo:
    gr.Markdown("# 🔍 Fraud Detection Demo")
    gr.Markdown("Enter transaction details or text and get prediction from the ML model.")

    inp = gr.Textbox(label="Enter Transaction Text / Data", lines=3, placeholder="Type something...")
    out = gr.Textbox(label="Model Prediction")
    btn = gr.Button("Predict")

    btn.click(fn=ui_predict, inputs=inp, outputs=out)

if __name__ == "__main__":
    demo.launch(server_name="0.0.0.0", server_port=7860)