Ayesha352 commited on
Commit
191b826
·
verified ·
1 Parent(s): 5204d1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -95,15 +95,19 @@ def alpr_color_inference(image):
95
  # ------------------ Gradio UI ------------------
96
  with gr.Blocks() as demo:
97
  gr.Markdown("# License Plate + Vehicle Color Detection")
 
98
  with gr.Row():
99
  with gr.Column():
100
- image_input = gr.Image(type="pil", label="Upload an image", show_clear_button=True)
101
- submit_btn = gr.Button("Run Detection")
 
 
 
102
  with gr.Column():
103
  plate_output = gr.Image(label="Combined Detection Output")
104
  vehicle_output = gr.Image(label="(Optional) Cropped Vehicle")
105
  cropped_output = gr.Image(label="(Optional) Cropped Vehicle Region")
106
- result_text = gr.Markdown(label="Results")
107
 
108
  submit_btn.click(
109
  alpr_color_inference,
@@ -111,12 +115,28 @@ with gr.Blocks() as demo:
111
  outputs=[plate_output, vehicle_output, cropped_output, result_text]
112
  )
113
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  gr.Examples(
115
  examples=[
116
  "examples/car1.jpg",
117
  "examples/car2.jpg",
118
  "examples/car3.jpg",
119
  "examples/car4.jpg",
 
 
 
 
120
  ],
121
  inputs=[image_input],
122
  label="Example Images"
 
95
  # ------------------ Gradio UI ------------------
96
  with gr.Blocks() as demo:
97
  gr.Markdown("# License Plate + Vehicle Color Detection")
98
+
99
  with gr.Row():
100
  with gr.Column():
101
+ image_input = gr.Image(type="pil", label="Upload an image", show_clear_button=False)
102
+ with gr.Row():
103
+ submit_btn = gr.Button("Submit", variant="primary")
104
+ clear_btn = gr.Button("Cancel", variant="stop") # Red cancel button
105
+
106
  with gr.Column():
107
  plate_output = gr.Image(label="Combined Detection Output")
108
  vehicle_output = gr.Image(label="(Optional) Cropped Vehicle")
109
  cropped_output = gr.Image(label="(Optional) Cropped Vehicle Region")
110
+ result_text = gr.Markdown()
111
 
112
  submit_btn.click(
113
  alpr_color_inference,
 
115
  outputs=[plate_output, vehicle_output, cropped_output, result_text]
116
  )
117
 
118
+ # Clear button logic: reset everything
119
+ clear_btn.click(
120
+ lambda: (None, None, None, ""), # Empty results
121
+ inputs=[],
122
+ outputs=[plate_output, vehicle_output, cropped_output, result_text]
123
+ )
124
+ clear_btn.click(
125
+ lambda: None,
126
+ inputs=[],
127
+ outputs=[image_input]
128
+ )
129
+
130
  gr.Examples(
131
  examples=[
132
  "examples/car1.jpg",
133
  "examples/car2.jpg",
134
  "examples/car3.jpg",
135
  "examples/car4.jpg",
136
+ "examples/car5.jpg",
137
+ "examples/car6.jpg",
138
+ "examples/car7.jpg",
139
+ "examples/car8.jpg",
140
  ],
141
  inputs=[image_input],
142
  label="Example Images"