GAP_SMALL_PROJECT / tabs /batch_processing.py
fatimaxa's picture
Update tabs/batch_processing.py
6fcb290 verified
import gradio as gr
from utils.predictions import predict_batch_visual
def create_batch_processing_tab(model, class_names, device):
"""Create the batch processing tab"""
def batch_predict_wrapper(files):
if not files:
return None, "❌ No files uploaded. Please select images to process."
# No progress parameter in Gradio 6
gallery, results = predict_batch_visual(files, model, class_names, device)
return gallery, results
gr.Markdown("""
### πŸ“ Upload multiple images for batch prediction
Upload several plant leaf images at once to get predictions for all of them.
Results will show each image with its prediction and confidence score.
""")
batch_input = gr.File(
file_count="multiple",
label="Upload Multiple Images",
type="filepath"
)
batch_btn = gr.Button("πŸš€ Process All Images", variant="primary", size="lg")
with gr.Row():
batch_gallery = gr.Gallery(
label="Processed Images",
columns=3,
height="auto",
object_fit="contain"
)
batch_output = gr.Markdown(label="πŸ“Š Detailed Results")
batch_btn.click(
fn=batch_predict_wrapper,
inputs=batch_input,
outputs=[batch_gallery, batch_output]
)
return batch_input, batch_btn, batch_gallery, batch_output