|
import gradio as gr |
|
from umpire_decision import simulate_umpire_decision |
|
from drs_review import analyze_drs |
|
from final_decision import compare_decisions |
|
|
|
def lbw_decision_app(pitch_zone, shot_offered, impact_zone, ball_tracking): |
|
|
|
onfield = simulate_umpire_decision(pitch_zone, shot_offered, impact_zone, ball_tracking) |
|
|
|
|
|
drs_result = analyze_drs(ball_tracking) |
|
|
|
|
|
final = compare_decisions(onfield, drs_result) |
|
|
|
return f"""π **On-field Decision**: {onfield['decision']} |
|
π Reason: {onfield['reason']} |
|
|
|
π§ͺ **DRS Verdict**: {'CONFIRMED β
' if final['confirmed'] else 'OVERTURNED β'} |
|
π DRS Analysis: {drs_result['reason']} |
|
|
|
β
**Final Decision**: {final['final_decision']}""" |
|
|
|
iface = gr.Interface( |
|
fn=lbw_decision_app, |
|
inputs=[ |
|
gr.Radio(["In Line", "Outside Off", "Outside Leg"], label="Pitch Location"), |
|
gr.Radio(["Yes", "No"], label="Was Shot Offered?"), |
|
gr.Radio(["In Line", "Outside Off", "Outside Leg"], label="Impact Zone"), |
|
gr.Textbox(label="Ball Tracking Data (JSON format)", placeholder='{"pitching": "in line", "impact": "in line", "trajectory": "hitting"}'), |
|
], |
|
outputs="markdown", |
|
title="Smart LBW Decision Review System", |
|
description="Simulates on-field umpire call and DRS-based final decision." |
|
) |
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|