--- language: - zh license: mit tags: - computer-vision - image-classification - convnextv2 - insect-identification - agriculture - pest-detection datasets: - custom widget: - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/tiger.jpg example_title: Tiger - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/teapot.jpg example_title: Teapot - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/palace.jpg example_title: Palace --- # ConvNextV2 玉米害虫识别模型 这是一个基于ConvNextV2架构训练的玉米害虫图像分类模型,专门用于识别8种常见玉米害虫。 ## 模型详情 - **模型架构**: ConvNextV2 Tiny - **输入尺寸**: 224x224 RGB图像 - **输出类别**: 8种玉米害虫 - **训练数据**: 自定义玉米害虫数据集 - **用途**: 农业害虫监测与识别 ## 类别标签 [ "草地贪夜蛾", "赤须盲蝽", "点蜂缘蝽", "龟纹瓢虫", "棉铃虫", "茄二十八星瓢虫", "双斑长跗萤叶甲", "玉米螟" ] ## 使用方法 ### 使用Transformers库 ```python from transformers import AutoImageProcessor, AutoModelForImageClassification import torch from PIL import Image # 加载模型和处理器 model_name = "Jaysaly/cornlarva_convnextv2" processor = AutoImageProcessor.from_pretrained(model_name) model = AutoModelForImageClassification.from_pretrained(model_name) # 准备图像 image = Image.open("path_to_image.jpg").convert("RGB") inputs = processor(images=image, return_tensors="pt") # 推理 with torch.no_grad(): outputs = model(**inputs) logits = outputs.logits predicted_class_idx = logits.argmax(-1).item() # 获取预测结果 predicted_label = model.config.id2label[str(predicted_class_idx)] print(f"预测结果: {predicted_label}") ``` ### 使用Hugging Face Inference API ```python import requests API_URL = "https://api-inference.huggingface.co/models/Jaysaly/cornlarva_convnextv2" headers = {"Authorization": "Bearer YOUR_HF_TOKEN"} def query(image_bytes): response = requests.post(API_URL, headers=headers, data=image_bytes) return response.json() ``` ## 训练信息 - **框架**: PyTorch - **优化器**: AdamW - **学习率**: 1e-4 - **批次大小**: 32 - **训练周期**: 100 - **数据增强**: 随机裁剪、水平翻转、颜色抖动 ## 应用场景 1. **智能农业监测**: 自动识别田间害虫 2. **病虫害预警**: 及时发现害虫爆发 3. **精准施药**: 针对特定害虫采取防治措施 4. **科研教育**: 害虫识别教学与研究 ## 性能指标 在验证集上的Top-1准确率: ~95% ## 限制 - 仅支持训练数据中的8种玉米害虫 - 需要清晰的昆虫特写图像 - 对背景复杂的图片识别效果可能下降 ## 作者 Jaysaly ## 许可证 MIT License