自学内容网 自学内容网

Coggle数据科学 | 科大讯飞AI大赛:玉米雄穗识别挑战赛

本文来源公众号“Coggle数据科学”,仅用于学术分享,侵权删,干货满满。

原文链接:科大讯飞AI大赛:玉米雄穗识别挑战赛

  • 赛题名称:玉米雄穗识别挑战赛

  • 赛题类型:计算机视觉、物体检测

  • 赛题任务:通过田间图像正确识别植株雄穗,并进行标注。

报名链接:https://challenge.xfyun.cn/topic/info?type=corn-tassel&ch=dw24_AtTCK9

赛事背景

随着中国经济发展和人口增长,对农业生产的需求不断增加,玉米作为重要的粮食作物之一,一直处于国家粮食安全和生态保护的重要位置。玉米制种产业是玉米生产的基础保障。随着玉米制种技术的不断发展,不育系生产由于无需去雄,节省劳动力,已经越来越普及。在玉米种子生产过程中,母本去雄作为种子纯度保障至关重要的环节,准确识别母本去雄后残留雄穗并去除是提升种子质量的重要手段。

赛事任务

在玉米花期,通过田间图像正确识别植株雄穗,并进行标注。

数据说明

本次比赛将会为选手提供玉米处于花期阶段的图片作为数据集,选手需要根据训练集进行训练,对测试集数据进行标定。

评估指标

本赛题对目标检测结果采用F1-score ( IoU0.5 记为TP )进行评价。

赛题 Baseline

  • 划分验证集

import os
import glob
import shutil

os.makedirs('val', exist_ok=True)
os.makedirs('val/labels', exist_ok=True)
os.makedirs('val/images', exist_ok=True)

labels = glob.glob('./train/labels/*')
images = glob.glob('./train/images/*')

labels.sort(); images.sort()

for x, y in zip(labels[-50:], images[-50:]):
    shutil.move(x, 'val/labels/')
    shutil.move(y, 'val/images/')
  • 创建数据集配置

import os
dir_path = os.path.abspath('./') + '/'

# 需要按照你的修改path
with open('yolo.yaml', 'w', encoding='utf-8') as up:
    up.write(f'''
path: {dir_path}/
train: train/
val: val/

names:
    0: tas
''')
  • 训练 YOLO 模型

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"

import warnings
warnings.filterwarnings('ignore')


from ultralytics import YOLO
model = YOLO("yolov8m.pt")
results = model.train(data="./yolo.yaml", epochs=40, device=1, batch=16)
  • 测试集预测

# 加载最优模型
model = YOLO("runs/detect/train5/weights/best.pt")

os.makedirs('submit', exist_ok=True)
test_paths = glob.glob('test/*')

for path in test_paths:
    predictions = model(path, save_txt=None)
    with open("./submit/" + path.split('/')[-1][:-4] + '.txt', '+w') as file:
          for idx, prediction in enumerate(predictions[0].boxes.xywhn): # change final attribute to desired box format
              cls = int(predictions[0].boxes.cls[idx].item())
              # Write line to file in YOLO label format : cls x y w h
              file.write(f"{cls} {prediction[0].item()} {prediction[1].item()} {prediction[2].item()} {prediction[3].item()}\n")

完整代码见:

https://github.com/datawhalechina/competition-baseline/tree/master/competition/%E7%A7%91%E5%A4%A7%E8%AE%AF%E9%A3%9EAI%E5%BC%80%E5%8F%91%E8%80%85%E5%A4%A7%E8%B5%9B2024

THE END !

文章结束,感谢阅读。您的点赞,收藏,评论是我继续更新的动力。大家有推荐的公众号可以评论区留言,共同学习,一起进步。


原文地址:https://blog.csdn.net/csdn_xmj/article/details/142307929

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!