Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from umpire_decision import simulate_umpire_decision
|
| 3 |
+
from drs_review import analyze_drs
|
| 4 |
+
from final_decision import compare_decisions
|
| 5 |
+
|
| 6 |
+
def lbw_decision_app(pitch_zone, shot_offered, impact_zone, ball_tracking):
|
| 7 |
+
# Step 1 - On-field
|
| 8 |
+
onfield = simulate_umpire_decision(pitch_zone, shot_offered, impact_zone, ball_tracking)
|
| 9 |
+
|
| 10 |
+
# Step 2 - DRS
|
| 11 |
+
drs_result = analyze_drs(ball_tracking)
|
| 12 |
+
|
| 13 |
+
# Step 3 - Final Comparison
|
| 14 |
+
final = compare_decisions(onfield, drs_result)
|
| 15 |
+
|
| 16 |
+
return f"""π **On-field Decision**: {onfield['decision']}
|
| 17 |
+
π Reason: {onfield['reason']}
|
| 18 |
+
|
| 19 |
+
π§ͺ **DRS Verdict**: {'CONFIRMED β
' if final['confirmed'] else 'OVERTURNED β'}
|
| 20 |
+
π DRS Analysis: {drs_result['reason']}
|
| 21 |
+
|
| 22 |
+
β
**Final Decision**: {final['final_decision']}"""
|
| 23 |
+
|
| 24 |
+
iface = gr.Interface(
|
| 25 |
+
fn=lbw_decision_app,
|
| 26 |
+
inputs=[
|
| 27 |
+
gr.Radio(["In Line", "Outside Off", "Outside Leg"], label="Pitch Location"),
|
| 28 |
+
gr.Radio(["Yes", "No"], label="Was Shot Offered?"),
|
| 29 |
+
gr.Radio(["In Line", "Outside Off", "Outside Leg"], label="Impact Zone"),
|
| 30 |
+
gr.Textbox(label="Ball Tracking Data (JSON format)", placeholder='{"pitching": "in line", "impact": "in line", "trajectory": "hitting"}'),
|
| 31 |
+
],
|
| 32 |
+
outputs="markdown",
|
| 33 |
+
title="Smart LBW Decision Review System",
|
| 34 |
+
description="Simulates on-field umpire call and DRS-based final decision."
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
iface.launch()
|