Spaces:
Runtime error
Runtime error
File size: 1,457 Bytes
4a693a1 83be575 | 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 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, progress=gr.Progress()):
if not files:
return None, "No files uploaded. Please select images to process."
progress(0, desc="Starting batch processing...")
gallery, results = predict_batch_visual(files, model, class_names, device, progress)
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",
file_types=["image"]
)
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 |