文章前瞻:优质数据集与检测系统精选
点击链接:更多数据集与系统目录清单
一、海洋生物识别数据集介绍
【数据集】yolov8水下生物检测数据集 7507 张,目标检测,包含YOLO/VOC格式标注,训练、验证、测试集已划分。
数据集中标签包含5种分类:names: ['echinus', 'holothurian', 'scallop', 'starfish', 'waterweeds'],代表海胆,海参,扇贝,海星,水草。
检测场景为河道、海岸、海底、水下、捕鱼厂等场景,可用于海洋生态保护、渔业资源精准管理、海洋环境预警、海洋科研支撑等。
文章底部名片或主页私信获取数据集和系统~


1、数据概述
海洋生物识别的重要性
海洋生物是海洋生态系统的核心组成,其种群数量、分布范围直接反映海洋环境健康状况,同时关联渔业资源可持续利用与海洋安全。但传统海洋生物检测存在显著局限:人工科考依赖潜水员采样或科考船拖网,不仅覆盖范围有限,还易对海洋生物造成惊扰或伤害,尤其难以触及深海、极地等极端区域;光学观测后需人工识别生物种类,效率低下,且对形态相似物种易出现误判;数据记录与分析滞后,难以及时捕捉生物种群的动态变化,无法为生态保护提供实时支撑。
YOLO算法凭借“实时目标检测+高适应性”的优势破解上述难题:其一,可搭载于水下机器人、无人机、卫星遥感设备,实现从浅海到深海、近岸到远洋的全范围覆盖,无需人工直接介入;其二,能快速识别画面中各类海洋生物,精准区分物种差异(如区分不同珊瑚种类、鱼类幼体与成体),即使在浑浊水体、低光照等复杂环境下也能保持稳定识别能力;其三,检测数据可实时回传并自动分类统计,为生态监测、资源管理提供高效数据支撑,推动海洋研究从“间歇性采样”向“持续性监测”转型。
基于YOLO的水下生物检测系统
-
海洋生态保护:YOLO可长期追踪濒危物种(如中华白海豚、珊瑚礁鱼类)的活动轨迹与种群数量,及时发现其栖息地受污染、破坏等异常情况,为保护区划定、生态修复方案制定提供依据。同时,能快速识别外来入侵物种(如狮子鱼)的扩散范围,助力提前采取防控措施,避免破坏本地生态平衡。
-
渔业资源精准管理:通过检测鱼群种类、密度与规模,YOLO可辅助渔业部门判断渔业资源储量,明确禁渔期、禁渔区的科学边界,避免过度捕捞。在捕捞作业中,可联动渔具设备识别保护物种,及时发出预警,减少误捕情况,保障渔业资源可持续利用。
-
海洋环境预警:部分海洋生物的异常聚集或行为变化是环境恶化的信号,如赤潮爆发前浮游生物会大量增殖。YOLO可通过持续监测捕捉这类异常,快速联动环境监测系统发出预警,为沿海养殖区、核电站取水口等关键区域争取应对时间,减少经济损失。
-
海洋科研支撑:在海洋生物学研究中,YOLO可自动记录生物的摄食、繁殖、洄游等行为数据,替代人工长期观测的繁琐工作。尤其在深海生物研究中,能帮助科研人员获取此前难以触及的物种信息,推动深海生态、生物进化等领域的研究突破。
该数据集含有 7507 张图片,包含Pascal VOC XML格式和YOLO TXT格式,用于训练和测试河道、海岸、海底、水下、捕鱼厂等场景进行水下生物识别。
图片格式为jpg格式,标注格式分别为:
YOLO:txt
VOC:xml
数据集均为手工标注,保证标注精确度。
2、数据集文件结构
marine_life/
——test/
————Annotations/
————images/
————labels/
——train/
————Annotations/
————images/
————labels/
——valid/
————Annotations/
————images/
————labels/
——data.yaml
- 该数据集已划分训练集样本,分别是:test目录(测试集)、train目录(训练集)、valid目录(验证集);
- Annotations文件夹为Pascal VOC格式的XML文件 ;
- images文件夹为jpg格式的数据样本;
- labels文件夹是YOLO格式的TXT文件;
- data.yaml是数据集配置文件,包含海洋生物检测的目标分类和加载路径。




Annotations目录下的xml文件内容如下:
<?xml version="1.0" encoding="utf-8"?>
<annotation>
<folder>driving_annotation_dataset</folder>
<filename>100379.jpg</filename>
<size>
<width>640</width>
<height>640</height>
<depth>3</depth>
</size>
<object>
<name>holothurian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>330</xmin>
<ymin>387</ymin>
<xmax>386</xmax>
<ymax>429</ymax>
</bndbox>
</object>
<object>
<name>starfish</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>106</xmin>
<ymin>344</ymin>
<xmax>167</xmax>
<ymax>443</ymax>
</bndbox>
</object>
<object>
<name>starfish</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>186</xmin>
<ymin>413</ymin>
<xmax>226</xmax>
<ymax>495</ymax>
</bndbox>
</object>
<object>
<name>starfish</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>125</xmin>
<ymin>510</ymin>
<xmax>177</xmax>
<ymax>587</ymax>
</bndbox>
</object>
<object>
<name>holothurian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>165</xmin>
<ymin>522</ymin>
<xmax>201</xmax>
<ymax>624</ymax>
</bndbox>
</object>
<object>
<name>holothurian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>163</xmin>
<ymin>360</ymin>
<xmax>213</xmax>
<ymax>416</ymax>
</bndbox>
</object>
<object>
<name>starfish</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>429</xmin>
<ymin>28</ymin>
<xmax>467</xmax>
<ymax>62</ymax>
</bndbox>
</object>
<object>
<name>holothurian</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>219</xmin>
<ymin>77</ymin>
<xmax>235</xmax>
<ymax>127</ymax>
</bndbox>
</object>
</annotation>
labels目录下的txt文件内容如下:
0 0.12465277777777777 0.14205246913580247 0.05555555555555556 0.07160493827160494
0 0.1814236111111111 0.3164158950617284 0.07222222222222222 0.12345679012345678
0 0.21597222222222223 0.254224537037037 0.04444444444444444 0.07407407407407407
0 0.22777777777777777 0.07650462962962963 0.043055555555555555 0.059259259259259255
0 0.39600694444444445 0.1054591049382716 0.05138888888888889 0.0765432098765432
0 0.4256944444444445 0.0601466049382716 0.05138888888888889 0.0765432098765432
0 0.4331597222222222 0.1626929012345679 0.04444444444444444 0.0691358024691358
0 0.47100694444444446 0.20462962962962963 0.02638888888888889 0.059259259259259255
0 0.39565972222222223 0.3564621913580247 0.05694444444444444 0.11604938271604937
0 0.2420138888888889 0.46986882716049383 0.07777777777777777 0.12098765432098765
0 0.17638888888888887 0.5609953703703704 0.09027777777777776 0.14074074074074075
0 0.12604166666666666 0.05694444444444444 0.05833333333333333 0.08888888888888888
0 0.2984375 0.4805555555555555 0.05 0.11111111111111112
0 0.818576388888889 0.2749614197530864 0.05277777777777778 0.10617283950617282
1 0.5894097222222222 0.4251929012345679 0.05694444444444444 0.0691358024691358
1 0.6236111111111111 0.9210069444444444 0.08472222222222223 0.08888888888888888
3 0.878125 0.09837962962962962 0.0625 0.059259259259259255
3、数据集适用范围
- 目标检测场景,监控识别
- yolo训练模型或其他模型
- 河道、海岸、海底、水下、捕鱼厂
- 可用于海洋生态保护、渔业资源精准管理、海洋环境预警、海洋科研支撑等
4、数据集标注结果




4.1、数据集内容
- 场景视角:监控视角数据样本,人员视角数据样本;
- 标注内容:names: ['echinus', 'holothurian', 'scallop', 'starfish', 'waterweeds'],总计5个分类;
- 图片总量:7507 张图片数据;
- 标注类型:含有Pascal VOC XML格式和yolo TXT格式;
5、训练过程
5.1、导入训练数据
下载YOLOv8项目压缩包,解压在任意本地workspace文件夹中。
下载YOLOv8预训练模型,导入到ultralytics-main项目根目录下。
在ultralytics-main项目根目录下,创建data文件夹,并在data文件夹下创建子文件夹:Annotations、images、imageSets、labels,其中,将pascal VOC格式的XML文件手动导入到Annotations文件夹中,将JPG格式的图像数据导入到images文件夹中,imageSets和labels两个文件夹不导入数据。
data目录结构如下:
data/
——Annotations/ //存放xml文件
——images/ //存放jpg图像
——imageSets/
——labels/
整体项目结构如下所示:
5.2、数据分割
首先在ultralytics-main目录下创建一个split_train_val.py文件,运行文件之后会在imageSets文件夹下将数据集划分为训练集train.txt、验证集val.txt、测试集test.txt,里面存放的就是用于训练、验证、测试的图片名称。
import os
import random
trainval_percent = 0.9
train_percent = 0.9
xmlfilepath = 'data/Annotations'
txtsavepath = 'data/ImageSets'
total_xml = os.listdir(xmlfilepath)
num = len(total_xml)
list = range(num)
tv = int(num * trainval_percent)
tr = int(tv * train_percent)
trainval = random.sample(list, tv)
train = random.sample(trainval, tr)
ftrainval = open('data/ImageSets/trainval.txt', 'w')
ftest = open('data/ImageSets/test.txt', 'w')
ftrain = open('data/ImageSets/train.txt', 'w')
fval = open('data/ImageSets/val.txt', 'w')
for i in list:
name = total_xml[i][:-4] + '\n'
if i in trainval:
ftrainval.write(name)
if i in train:
ftrain.write(name)
else:
fval.write(name)
else:
ftest.write(name)
ftrainval.close()
ftrain.close()
fval.close()
ftest.close()
5.3、数据集格式化处理
在ultralytics-main目录下创建一个voc_label.py文件,用于处理图像标注数据,将其从XML格式(通常用于Pascal VOC数据集)转换为YOLO格式。
convert_annotation函数
-
这个函数读取一个图像的XML标注文件,将其转换为YOLO格式的文本文件。
-
它打开XML文件,解析树结构,提取图像的宽度和高度。
-
然后,它遍历每个目标对象(
object),检查其类别是否在classes列表中,并忽略标注为困难(difficult)的对象。 -
对于每个有效的对象,它提取边界框坐标,进行必要的越界修正,然后调用
convert函数将坐标转换为YOLO格式。 -
最后,它将类别ID和归一化后的边界框坐标写入一个新的文本文件
import xml.etree.ElementTree as ET
import os
from os import getcwd
sets = ['train', 'val', 'test']
classes = ['echinus', 'holothurian', 'scallop', 'starfish', 'waterweeds'] # 根据标签名称填写类别
abs_path = os.getcwd()
print(abs_path)
def convert(size, box):
dw = 1. / (size[0])
dh = 1. / (size[1])
x = (box[0] + box[1]) / 2.0 - 1
y = (box[2] + box[3]) / 2.0 - 1
w = box[1] - box[0]
h = box[3] - box[2]
x = x * dw
w = w * dw
y = y * dh
h = h * dh
return x, y, w, h
def convert_annotation(image_id):
in_file = open('data/Annotations/%s.xml' % (image_id), encoding='UTF-8')
out_file = open('data/labels/%s.txt' % (image_id), 'w')
tree = ET.parse(in_file)
root = tree.getroot()
size = root.find('size')
w = int(size.find('width').text)
h = int(size.find('height').text)
for obj in root.iter('object'):
difficult = obj.find('difficult').text
cls = obj.find('name').text
if cls not in classes or int(difficult) == 1:
continue
cls_id = classes.index(cls)
xmlbox = obj.find('bndbox')
b = (float(xmlbox.find('xmin').text),
float(xmlbox.find('xmax').text),
float(xmlbox.find('ymin').text),
float(xmlbox.find('ymax').text))
b1, b2, b3, b4 = b
# 标注越界修正
if b2 > w:
b2 = w
if b4 > h:
b4 = h
b = (b1, b2, b3, b4)
bb = convert((w, h), b)
out_file.write(str(cls_id) + " " + " ".join([str(a) for a in bb]) + '\n')
wd = getcwd()
for image_set in sets:
if not os.path.exists('data/labels/'):
os.makedirs('data/labels/')
image_ids = open('data/ImageSets/%s.txt' % (image_set)).read().strip().split()
list_file = open('data/%s.txt' % (image_set), 'w')
for image_id in image_ids:
list_file.write(abs_path + '/data/images/%s.jpg\n' % (image_id))
convert_annotation(image_id)
list_file.close()
5.4、修改数据集配置文件
在ultralytics-main目录下创建一个data.yaml文件
train: data/train.txt
val: data/val.txt
test: data/test.txt
nc: 5
names: ['echinus', 'holothurian', 'scallop', 'starfish', 'waterweeds']
5.5、执行命令
执行train.py
model = YOLO('yolov8s.pt')
results = model.train(data='data.yaml', epochs=200, imgsz=640, batch=16, workers=0)
也可以在终端执行下述命令:
yolo train data=data.yaml model=yolov8s.pt epochs=200 imgsz=640 batch=16 workers=0 device=0
5.6、模型预测
你可以选择新建predict.py预测脚本文件,输入视频流或者图像进行预测。
代码如下:
import cv2
from ultralytics import YOLO
# Load the YOLOv8 model
model = YOLO("./best.pt") # 自定义预测模型加载路径
# Open the video file
video_path = "./demo.mp4" # 自定义预测视频路径
cap = cv2.VideoCapture(video_path)
# Get the video properties
frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = cap.get(cv2.CAP_PROP_FPS)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # Be sure to use lower case
out = cv2.VideoWriter('./outputs.mp4', fourcc, fps, (frame_width, frame_height)) # 自定义输出视频路径
# Loop through the video frames
while cap.isOpened():
# Read a frame from the video
success, frame = cap.read()
if success:
# Run YOLOv8 inference on the frame
# results = model(frame)
results = model.predict(source=frame, save=True, imgsz=640, conf=0.5)
results[0].names[0] = "自行修改中文名称"
# Visualize the results on the frame
annotated_frame = results[0].plot()
# Write the annotated frame to the output file
out.write(annotated_frame)
# Display the annotated frame (optional)
cv2.imshow("YOLOv8 Inference", annotated_frame)
# Break the loop if 'q' is pressed
if cv2.waitKey(1) & 0xFF == ord("q"):
break
else:
# Break the loop if the end of the video is reached
break
# Release the video capture and writer objects
cap.release()
out.release()
cv2.destroyAllWindows()
图片推理,代码如下:
import warnings
warnings.filterwarnings('ignore')
from ultralytics import YOLO
if __name__ == '__main__':
model = YOLO('models/best.pt')
model.predict(source='test_pic',
imgsz=640,
save=True,
conf=0.25
)
也可以直接在命令行窗口或者Annoconda终端输入以下命令进行模型预测:
yolo predict model="best.pt" source='demo.jpg'
6、获取数据集
文章底部名片或主页私信获取数据集或检测系统~
二、YOLO海洋生物检测系统
1、功能介绍
1. 模型管理
支持自定义上传模型文件,一键加载所选模型,基于 YOLO 框架进行推理。
2. 图片检测
- 支持上传本地图片文件,自动完成格式校验。
- 对上传图片进行目标检测,检测结果以带有边框和标签的图片形式返回并展示。
- 检测结果可下载保存。
3. 视频检测与实时流
- 支持上传本地视频文件,自动完成格式校验。
- 对视频逐帧检测,检测结果通过 MJPEG 流实时推送到前端页面,用户可边看边等。
- 支持摄像头实时检测(如有接入摄像头)。
4. 置信度阈值调节
- 前端可实时调整检测置信度阈值,动态影响检测结果。
- 阈值调整后,后端推理自动应用新阈值,无需重启。
5. 日志与状态反馈
- 前端集成日志区,实时显示模型加载、推理、文件上传等操作的进度与结果。
- 检测异常、错误信息及时反馈,便于排查。
- 一键清空日志,笔面长期占用内存。
2、创建环境并安装依赖:
conda create -n ultralytics-env python=3.10
conda activate ultralytics-env
pip install -r requirements.txt
3、启动项目
python app.py
打开浏览器访问:http://localhost:5000
4、效果展示
4.1、推理效果

4.2、日志文本框

4.3、摄像头检测

5、前端核心页面代码
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>视觉检测系统 - Web UI</title>
<link rel="stylesheet" href="/static/style.css">
<link rel="icon" href="/favicon.ico">
</head>
<body>
<div class="container main-flex">
<!-- 左侧内容区 -->
<div class="left-content">
<header>
<h1>YOLO海洋生物检测系统</h1>
<div id="currentModelDisplay" class="modelDisplay" title="当前模型">当前模型:未上传模型</div>
</header>
<main>
<div class="videoPanel">
<div class="pane">
<h3>原图 / 视频</h3>
<div class="preview" id="srcPreview">预览区</div>
</div>
<div class="pane">
<h3>检测结果</h3>
<div class="preview" id="detPreview">检测结果</div>
</div>
</div>
<section class="logArea">
<div class="logHeader">
<h3>日志</h3>
</div>
<div class="logInner">
<div id="logs" class="logs"></div>
</div>
</section>
</main>
</div>
<!-- 右侧按钮栏 -->
<aside class="right-bar">
<!-- 1. 模型上传/加载区 -->
<section class="model-section">
<button id="uploadModelBtn" class="ghost">上传模型
<input id="modelFileInput" type="file" accept=".pt" title="选择 .pt 模型文件">
</button>
<button id="loadModel">加载模型</button>
</section>
<!-- 2. 检测方式选择区 -->
<section class="detect-mode-section">
<div class="detect-mode-title">请选择检测方式</div>
<div class="detect-mode-radio-group">
<label><input type="radio" name="detectMode" value="upload" checked> 图片/视频</label>
<label><input type="radio" name="detectMode" value="camera"> 摄像头</label>
</div>
<div id="detectModeUpload" class="detect-mode-panel">
<div class="uploaded-file-name">
<span id="uploadedFileName" class="placeholder">未选择文件</span>
</div>
<div style="height: 22px;"></div>
<button id="uploadBtn">上传文件
<input id="fileInput" type="file" accept="image/*,video/*" title="上传图片或视频" aria-label="上传图片或视频">
</button>
</div>
<div id="detectModeCamera" class="detect-mode-panel" style="display:none;">
<button id="cameraDetectBtn" class="ghost">开启摄像头</button>
<div id="cameraPreview" class="camera-preview">
<video id="localCameraVideo" autoplay muted playsinline></video>
<div class="camera-controls">
<button id="stopCameraBtn" class="ghost">关闭摄像头</button>
</div>
</div>
</div>
<div class="confWrap">
<label class="conf">置信度
<input id="confRange" type="range" min="0.01" max="0.99" step="0.01" value="0.5">
<input id="confValue" type="number" min="0.01" max="0.99" step="0.01" value="0.5">
</label>
</div>
</section>
<!-- 3. 操作按钮区 -->
<section class="action-btn-section">
<button id="startBtn" disabled class="start">开始检测</button>
<button id="stopBtn" disabled class="stop">停止</button>
<button id="clearLogs" class="ghost">清空日志</button>
</section>
</aside>
</div>
<script src="/static/app.js"></script>
</body>
</html>
6、代码获取
文章底部名片或私信获取系统源码和数据集~
以上内容均为原创。
1833

被折叠的 条评论
为什么被折叠?



