0 前言
?? Hi,大家好,這里是丹成學(xué)長的畢設(shè)系列文章!
?? 對畢設(shè)有任何疑問都可以問學(xué)長哦!
這兩年開始,各個學(xué)校對畢設(shè)的要求越來越高,難度也越來越大… 畢業(yè)設(shè)計耗費時間,耗費精力,甚至有些題目即使是專業(yè)的老師或者碩士生也需要很長時間,所以一旦發(fā)現(xiàn)問題,一定要提前準(zhǔn)備,避免到后面措手不及,草草了事。
為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項目,今天要分享的新項目是
?? 深度學(xué)習(xí)衛(wèi)星遙感圖像檢測與識別
??學(xué)長這里給一個題目綜合評分(每項滿分5分)
- 難度系數(shù):4分
- 工作量:4分
- 創(chuàng)新點:3分
?? 選題指導(dǎo), 項目分享:
https://gitee.com/yaa-dc/BJH/blob/master/gg/cc/README.md
1 課題背景
近年來,世界各國大力發(fā)展航空航天事業(yè),衛(wèi)星圖像的目標(biāo)檢測在各行各業(yè)的應(yīng)用得到了快速的發(fā)展,特別是軍事偵查、海洋船舶和漁業(yè)管理等領(lǐng)域。由于衛(wèi)星圖像中有價值的信息極少,衛(wèi)星圖像數(shù)據(jù)規(guī)模巨大,這迫切需要智能輔助工具幫助相關(guān)從業(yè)人員從衛(wèi)星圖像中高效獲取精確直觀的信息。
本文利用深度學(xué)習(xí)技術(shù),基于Yolov5算法框架實現(xiàn)衛(wèi)星圖像目標(biāo)檢測問題。
2 實現(xiàn)效果
實現(xiàn)效果如下:可以看出對船只、飛機等識別效果還是很好的。
3 Yolov5算法
簡介
下圖所示為 YOLOv5 的網(wǎng)絡(luò)結(jié)構(gòu)圖,分為輸入端,Backbone,Neck 和 Prediction 四個部分。其中,
輸入端包括 Mosaic 數(shù)據(jù)增強、自適應(yīng)圖片縮放、自適應(yīng)錨框計算,Backbone 包括 Focus 結(jié)構(gòu)、CSP
結(jié) 構(gòu),Neck 包 括 FPN+PAN 結(jié) 構(gòu),Prediction 包 括GIOU_Loss 結(jié)構(gòu)。
相關(guān)代碼
class Yolo(object):
def __init__(self, weights_file, verbose=True):
self.verbose = verbose
# detection params
self.S = 7 # cell size
self.B = 2 # boxes_per_cell
self.classes = ["aeroplane", "bicycle", "bird", "boat", "bottle",
"bus", "car", "cat", "chair", "cow", "diningtable",
"dog", "horse", "motorbike", "person", "pottedplant",
"sheep", "sofa", "train","tvmonitor"]
self.C = len(self.classes) # number of classes
# offset for box center (top left point of each cell)
self.x_offset = np.transpose(np.reshape(np.array([np.arange(self.S)]*self.S*self.B),
[self.B, self.S, self.S]), [1, 2, 0])
self.y_offset = np.transpose(self.x_offset, [1, 0, 2])
self.threshold = 0.2 # confidence scores threhold
self.iou_threshold = 0.4
# the maximum number of boxes to be selected by non max suppression
self.max_output_size = 10
self.sess = tf.Session()
self._build_net()
self._build_detector()
self._load_weights(weights_file)
4 數(shù)據(jù)處理和訓(xùn)練
數(shù)據(jù)集
本項目使用 DOTA 數(shù)據(jù)集,原數(shù)據(jù)集中待檢測的目標(biāo)如下
原數(shù)據(jù)集中的標(biāo)簽如下
圖像分割和尺寸調(diào)整
YOLO 模型的圖像輸入尺寸是固定的,由于原數(shù)據(jù)集中的圖像尺寸不一,我們將原數(shù)據(jù)集中的圖像按目標(biāo)分布的位置分割成一個個包含目標(biāo)的子圖,并將每個子圖尺寸調(diào)整為 1024×1024。分割前后的圖像如所示。
分割前
分割后
模型訓(xùn)練
在 yolov5/ 目錄,運行 train.py 文件開始訓(xùn)練:
python train.py --weight weights/yolov5s.pt --batch 16 --epochs 100 --cache
其中的參數(shù)說明:
- weight:使用的預(yù)訓(xùn)練權(quán)重,這里示范使用的是 yolov5s 模型的預(yù)訓(xùn)練權(quán)重
- batch:mini-batch 的大小,這里使用 16
- epochs:訓(xùn)練的迭代次數(shù),這里我們訓(xùn)練 100 個 epoch
- cache:使用數(shù)據(jù)緩存,加速訓(xùn)練進程
相關(guān)代碼文章來源:http://www.zghlxwxcb.cn/news/detail-473973.html
#部分代碼
def train(hyp, opt, device, tb_writer=None):
logger.info(f'Hyperparameters {hyp}')
log_dir = Path(tb_writer.log_dir) if tb_writer else Path(opt.logdir) / 'evolve' # logging directory
wdir = log_dir / 'weights' # weights directory
os.makedirs(wdir, exist_ok=True)
last = wdir / 'last.pt'
best = wdir / 'best.pt'
results_file = str(log_dir / 'results.txt')
epochs, batch_size, total_batch_size, weights, rank = \
opt.epochs, opt.batch_size, opt.total_batch_size, opt.weights, opt.global_rank
# Save run settings
with open(log_dir / 'hyp.yaml', 'w') as f:
yaml.dump(hyp, f, sort_keys=False)
with open(log_dir / 'opt.yaml', 'w') as f:
yaml.dump(vars(opt), f, sort_keys=False)
# Configure
cuda = device.type != 'cpu'
init_seeds(2 + rank)
with open(opt.data) as f:
data_dict = yaml.load(f, Loader=yaml.FullLoader) # data dict
with torch_distributed_zero_first(rank):
check_dataset(data_dict) # check
train_path = data_dict['train']
test_path = data_dict['val']
nc, names = (1, ['item']) if opt.single_cls else (int(data_dict['nc']), data_dict['names']) # number classes, names
assert len(names) == nc, '%g names found for nc=%g dataset in %s' % (len(names), nc, opt.data) # check
# Model
pretrained = weights.endswith('.pt')
if pretrained:
with torch_distributed_zero_first(rank):
attempt_download(weights) # download if not found locally
ckpt = torch.load(weights, map_location=device) # load checkpoint
if 'anchors' in hyp and hyp['anchors']:
ckpt['model'].yaml['anchors'] = round(hyp['anchors']) # force autoanchor
model = Model(opt.cfg or ckpt['model'].yaml, ch=3, nc=nc).to(device) # create
exclude = ['anchor'] if opt.cfg else [] # exclude keys
state_dict = ckpt['model'].float().state_dict() # to FP32
state_dict = intersect_dicts(state_dict, model.state_dict(), exclude=exclude) # intersect
model.load_state_dict(state_dict, strict=False) # load
logger.info('Transferred %g/%g items from %s' % (len(state_dict), len(model.state_dict()), weights)) # report
else:
model = Model(opt.cfg, ch=3, nc=nc).to(device) # create
# Freeze
freeze = ['', ] # parameter names to freeze (full or partial)
if any(freeze):
for k, v in model.named_parameters():
if any(x in k for x in freeze):
print('freezing %s' % k)
v.requires_grad = False
# Optimizer
nbs = 64 # nominal batch size
accumulate = max(round(nbs / total_batch_size), 1) # accumulate loss before optimizing
hyp['weight_decay'] *= total_batch_size * accumulate / nbs # scale weight_decay
pg0, pg1, pg2 = [], [], [] # optimizer parameter groups
for k, v in model.named_parameters():
v.requires_grad = True
if '.bias' in k:
pg2.append(v) # biases
elif '.weight' in k and '.bn' not in k:
pg1.append(v) # apply weight decay
else:
pg0.append(v) # all else
訓(xùn)練開始時的日志信息文章來源地址http://www.zghlxwxcb.cn/news/detail-473973.html
5 最后
到了這里,關(guān)于【畢業(yè)設(shè)計】深度學(xué)習(xí)衛(wèi)星遙感圖像檢測與識別系統(tǒng)(目標(biāo)檢測)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!