import gradio as gr from ultralytics import YOLO from PIL import Image CONF_THRESH=0.332 IOU=0.4 model = YOLO("best.pt") def predict(image): results = model(image, verbose=False, conf=CONF_THRESH, iou=IOU, agnostic_nms=True) results[0].names = {0: 'bee', 1: 'stylopidae', 2: 'meloidae larvae'} bgr_result_img = results[0].plot() rgb_result_img = Image.fromarray(bgr_result_img[..., ::-1]) return rgb_result_img def main(): with gr.Blocks() as demo: gr.HTML("