从CTF到实战:拆解Python反序列化漏洞的‘魔术’陷阱与防御姿势
2026/3/31 8:49:10
基于深度学习YOLOv12神经网络实现农作物检测和识别,其能识别检测出11种农作物检测:names: ['bluegrass','chenopodium_album','cirsium_setosum','corn','sedge','cotton', 'nightshade', 'tomato', 'velvet','lettuce','radish']
具体图片见如下:
YOLO12 引入了一种以注意力为中心的架构,它脱离了之前 YOLO 模型中使用的传统 CNN 方法,但保留了许多应用所必需的实时推理速度。该模型通过在注意力机制和整体网络架构方面的创新方法,实现了最先进的目标检测精度,同时保持了实时性能。
主要功能:
# Ultralytics YOLO 🚀, AGPL-3.0 license from pathlib import Path from ultralytics.engine.model import Model from ultralytics.models import yolo from ultralytics.nn.tasks import ClassificationModel, DetectionModel, OBBModel, PoseModel, SegmentationModel, WorldModel from ultralytics.utils import ROOT, yaml_load class YOLO(Model): """YOLO (You Only Look Once) object detection model.""" def __init__(self, model="yolo11n.pt", task=None, verbose=False): """Initialize YOLO model, switching to YOLOWorld if model filename contains '-world'.""" path = Path(model) if "-world" in path.stem and path.suffix in {".pt", ".yaml", ".yml"}: # if YOLOWorld PyTorch model new_instance = YOLOWorld(path, verbose=verbose) self.__class__ = type(new_instance) self.__dict__ = new_instance.__dict__ else: # Continue with default YOLO initialization super().__init__(model=model, task=task, verbose=verbose) @property def task_map(self): """Map head to model, trainer, validator, and predictor classes.""" return { "classify": { "model": ClassificationModel, "trainer": yolo.classify.ClassificationTrainer, "validator": yolo.classify.ClassificationValidator, "predictor": yolo.classify.ClassificationPredictor, }, "detect": { "model": DetectionModel, "trainer": yolo.detect.DetectionTrainer, "validator": yolo.detect.DetectionValidator, "predictor": yolo.detect.DetectionPredictor, }, "segment": { "model": SegmentationModel, "trainer": yolo.segment.SegmentationTrainer, "validator": yolo.segment.SegmentationValidator, "predictor": yolo.segment.SegmentationPredictor, }, "pose": { "model": PoseModel, "trainer": yolo.pose.PoseTrainer, "validator": yolo.pose.PoseValidator, "predictor": yolo.pose.PosePredictor, }, "obb": { "model": OBBModel, "trainer": yolo.obb.OBBTrainer, "validator": yolo.obb.OBBValidator, "predictor": yolo.obb.OBBPredictor, }, } class YOLOWorld(Model): """YOLO-World object detection model.""" def __init__(self, model="yolov8s-world.pt", verbose=False) -> None: """ Initialize YOLOv8-World model with a pre-trained model file. Loads a YOLOv8-World model for object detection. If no custom class names are provided, it assigns default COCO class names. Args: model (str | Path): Path to the pre-trained model file. Supports *.pt and *.yaml formats. verbose (bool): If True, prints additional information during initialization. """ super().__init__(model=model, task="detect", verbose=verbose) # Assign default COCO class names when there are no custom names if not hasattr(self.model, "names"): self.model.names = yaml_load(ROOT / "cfg/datasets/coco8.yaml").get("names") @property def task_map(self): """Map head to model, validator, and predictor classes.""" return { "detect": { "model": WorldModel, "validator": yolo.detect.DetectionValidator, "predictor": yolo.detect.DetectionPredictor, "trainer": yolo.world.WorldTrainer, } } def set_classes(self, classes): """ Set classes. Args: classes (List(str)): A list of categories i.e. ["person"]. """ self.model.set_classes(classes) # Remove background if it's given background = " " if background in classes: classes.remove(background) self.model.names = classes # Reset method class names # self.predictor = None # reset predictor otherwise old names remain if self.predictor: self.predictor.model.names = classes第六步:整个工程的内容
有训练代码和训练好的模型以及训练过程,提供数据,提供GUI界面代码
项目完整文件下载请见演示与介绍视频的简介处给出:➷➷➷
https://www.bilibili.com/video/BV168miBsEDK/