hrsc2016 yolo
时间: 2025-01-24 15:02:43 浏览: 78
### HRSC2016 YOLO 数据集 下载 使用说明
#### 数据集概述
HRSC2016 是一个高分辨率光学卫星图像数据集,专门用于船舶识别任务。该数据集中包含了大量标注好的船只样本,适用于目标检测研究[^1]。
#### 获取方式
为了获取 HRSC2016 数据集并将其转换为适合 YOLO 模型训练使用的格式,可以按照如下方法操作:
- **官方渠道**: 可通过 CSDN 博客文章中的链接访问原始发布者提供的资源页面下载 hrsc2016 数据集。
- **第三方平台**: 部分科研机构或个人可能会共享经过处理后的版本,建议查阅相关学术论坛或 GitHub 上是否有合适的镜像站点。
#### 转换至YOLO格式
由于原生的 HRSC2016 并不直接支持 YOLO 的输入需求,因此需要额外步骤来完成这一过程:
- 对于旋转矩形的支持,需特别注意角度参数的调整以适应 YOLO v5 或更高版本的要求;
- 创建相应的 `.txt` 文件保存每张图片对应的标签信息;
具体实现可参考网络上已有的 Python 脚本实例,这些脚本能自动化上述流程并将结果导出成标准 YOLO 形式的文件夹结构。
```python
import xml.etree.ElementTree as ET
from pathlib import 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 main():
sets=[('train', 'images'), ('val', 'images')]
classes = ["ship"]
for image_set in sets:
image_ids = open(f'ImageSets/Main/{image_set}.txt').read().strip().split()
list_file = open(f'{image_set}.txt', 'w')
for image_id in image_ids:
in_file = open(f'Annotations/{image_id}.xml')
tree=ET.parse(in_file)
root = tree.getroot()
size = root.find('size')
w = int(size.find('width').text)
h = int(size.find('height').text)
out_file = open(f'labels/{image_id}.txt', 'w')
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))
bb = convert((w,h), b)
out_file.write(str(cls_id) + " " + " ".join([str(a) for a in bb]) + '\n')
if __name__ == '__main__':
main()
```
#### 相关论文介绍
对于希望深入了解 HRSC2016 数据集及其应用的研究人员来说,《A High Resolution Optical Satellite Image Dataset for Ship Recognition and Some New Baselines》这篇文献提供了详细的背景描述以及实验基线模型分析[^2]。
阅读全文
相关推荐


















