最近想訓(xùn)練遙感實(shí)例分割,縱觀博客發(fā)現(xiàn)較少相關(guān) iSAID數(shù)據(jù)集的切分及數(shù)據(jù)集轉(zhuǎn)換內(nèi)容,思來想去應(yīng)該在繁忙之中抽出時間寫個詳細(xì)的教程。
iSAID數(shù)據(jù)集下載
iSAID數(shù)據(jù)集鏈接
下載上述數(shù)據(jù)集。
百度網(wǎng)盤中的train和val中包含了實(shí)例和語義分割標(biāo)簽。
上述過程只能下載標(biāo)簽,原始圖像為DOTA,DOTA圖像鏈接
上述下載完畢后,
train圖像:1411張?jiān)紙D像;1411張實(shí)例標(biāo)簽;1411張語義標(biāo)簽。
將所有訓(xùn)練圖像放置在一起創(chuàng)建iSAID/train/
val圖像:458張?jiān)紙D像;458張實(shí)例標(biāo)簽;458張語義標(biāo)簽。
將所有驗(yàn)證圖像放置在一起創(chuàng)建iSAID/val/
切圖并分割標(biāo)簽
下載切圖代碼:切圖及標(biāo)簽轉(zhuǎn)換
如果不將圖像切分,則會造成顯存溢出,原因在于圖像具有較多實(shí)例,以及大分辨率。
根據(jù)readme運(yùn)行split.py,運(yùn)行時將’–set’,改為 default=“train,val”
此時執(zhí)行切圖運(yùn)算(時間較長)。
切割完畢后在iSAID_patches文件夾中
train/84087圖像數(shù)量
val/19024圖像數(shù)量
第二步:標(biāo)簽生成:
運(yùn)行preprocess.py。
注:需要安裝lycon庫,如果失敗,在ubuntu命令行執(zhí)行:
sudo apt-get install cmake build-essential libjpeg-dev libpng-dev
運(yùn)行完畢后將生成coco格式的大json文件。
轉(zhuǎn)成YOLO格式并訓(xùn)練
利用coco官方API統(tǒng)計(jì)一下目標(biāo)類別:
# -*- coding: utf-8 -*-
# -----------------------------------------------------
# Time : 2023/2/27 11:28
# Auth : Written by zuofengyuan
# File : 統(tǒng)計(jì)coco信息.py
# Copyright (c) Shenyang Pedlin Technolofy Co., Ltd.
# -----------------------------------------------------
"""
Description: TODO
"""
from pycocotools.coco import COCO
# 文件路徑
dataDir = r'l/'
dataType = 'train2017' #val2017
annFile = '{}/instances_{}.json'.format(dataDir, dataType)
# initialize COCO api for instance annotations
coco_train = COCO(annFile)
# display COCO categories and supercategories
# 顯示所有類別
cats = coco_train.loadCats(coco_train.getCatIds())
cat_nms = [cat['name'] for cat in cats]
print('COCO categories:\n{}'.format('\n'.join(cat_nms)) + '\n')
# 統(tǒng)計(jì)單個類別的圖片數(shù)量與標(biāo)注數(shù)量
for cat_name in cat_nms:
catId = coco_train.getCatIds(catNms=cat_name)
if cat_name == "person":
print(catId)
imgId = coco_train.getImgIds(catIds=catId)
annId = coco_train.getAnnIds(imgIds=imgId, catIds=catId, iscrowd=False)
print("{:<15} {:<6d} {:<10d}\n".format(cat_name, len(imgId), len(annId)))
if cat_name == "motorcycle":
print(catId)
imgId = coco_train.getImgIds(catIds=catId)
annId = coco_train.getAnnIds(imgIds=imgId, catIds=catId, iscrowd=False)
print("{:<15} {:<6d} {:<10d}\n".format(cat_name, len(imgId), len(annId)))
# 統(tǒng)計(jì)全部的類別及全部的圖片數(shù)量和標(biāo)注數(shù)量
print("NUM_categories: " + str(len(coco_train.dataset['categories'])))
print("NUM_images: " + str(len(coco_train.dataset['images'])))
print("NUM_annotations: " + str(len(coco_train.dataset['annotations'])))
loading annotations into memory...
Done (t=19.50s)
creating index...
index created!
COCO categories:
Small_Vehicle
Large_Vehicle
plane
storage_tank
ship
Swimming_pool
Harbor
tennis_court
Ground_Track_Field
Soccer_ball_field
baseball_diamond
Bridge
basketball_court
Roundabout
Helicopter
NUM_categories: 15
NUM_images: 28029
NUM_annotations: 704684
根據(jù)官方轉(zhuǎn)換代碼JSON-yolomask
將coco格式的大json數(shù)據(jù)轉(zhuǎn)換成總多yolo格式的關(guān)鍵點(diǎn)數(shù)據(jù),
更改yaml數(shù)據(jù)文件:
train: ../JSON2YOLO-master/new_dir/images/train2017 # train images (relative to 'path') 128 images
val: ../JSON2YOLO-master/new_dir/images/train2017 # val images (relative to 'path') 128 images
test: # test images (optional)
# Classes
names:
0: Small_Vehicle
1: Large_Vehicle
2: plane
3: ship
4: Swimming_pool
5: Harbor
6: tennis_court
7: Swimming_pool
8: Ground_Track_Field
9: Soccer_ball_field
10: baseball_diamond
11: Bridge
12: basketball_court
13: Roundabout
14: Helicopter
然后執(zhí)行更改配置后執(zhí)行文章來源:http://www.zghlxwxcb.cn/news/detail-440303.html
python segment/train.py
查看訓(xùn)練圖像
注:coco轉(zhuǎn)yolo mask格式鏈接:
官方鏈接文章來源地址http://www.zghlxwxcb.cn/news/detail-440303.html
到了這里,關(guān)于YOLOv5訓(xùn)練大規(guī)模的遙感實(shí)例分割數(shù)據(jù)集 iSAID從切圖到數(shù)據(jù)集制作及訓(xùn)練的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!