日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

yolov3 anchor 理解

發(fā)布時間:2025/4/5 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 yolov3 anchor 理解 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
yolov3 中的anchor 的框框是在訓練集中聚類所得,在yolov3 中每個格子有9個anchor
mask52= [0,1,2]mask26= [3,4,5]mask13= [6,7,8]anchors=[ 10,13, 16,30, 33,23,30,61, 62,45, 59,119,116,90, 156,198, 373,326]
  • yolov3 有9個anchor 點
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Apr 19 20:54:27 2021@author: ledi """#!/usr/bin/env python # -*- coding:utf-8 -*- import cv2 def showPrioriBox():#輸入圖片尺寸INPUT_SIZE = 416mask52= [0,1,2]mask26= [3,4,5]mask13= [6,7,8]#0--->(10,13) #1--->(16,30) .....anchors=[ 10,13, 16,30, 33,23,30,61, 62,45, 59,119,116,90, 156,198, 373,326]FEATURE_MAP_SIZE=26SHOW_ALL_FLAG = True # 顯示所有的方框GRID_SHOW_FLAG =True# cap = cv2.VideoCapture("street.jpg")picPath = './car.jpg'picName = picPath.split('/')[-1]img = cv2.imread(picPath)print("original img.shape: ",img.shape) # (1330, 1330, 3)img = cv2.resize(img,(INPUT_SIZE, INPUT_SIZE))# 顯示網(wǎng)格if GRID_SHOW_FLAG:height, width, channels = img.shapeGRID_SIZEX = int(INPUT_SIZE/FEATURE_MAP_SIZE)for x in range(0, width - 1, GRID_SIZEX):cv2.line(img, (x, 0), (x, height), (150, 150, 255), 1, 1) # x gridGRID_SIZEY = int(INPUT_SIZE / FEATURE_MAP_SIZE)for y in range(0, height - 1, GRID_SIZEY):cv2.line(img, (0, y), (width, y), (150, 150, 255), 1, 1) # x grid# END:顯示網(wǎng)格 # cv2.imshow('Hehe', img) # cv2.imwrite('./' + picName.split('.')[0] + '_grid.' + picName.split('.')[1], img)if SHOW_ALL_FLAG or FEATURE_MAP_SIZE==13:for ele in mask13:# print(ele)# import cv2 圖片 起點 終點 顏色 厚度# cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2 )# x1,y1 ------# | |# | |# | |# --------x2,y2cv2.rectangle(img, (int(INPUT_SIZE * 0.5 - 0.5*anchors[ ele * 2]), int(INPUT_SIZE * 0.5 - 0.5*anchors[ ele * 2 + 1]) ),(int(INPUT_SIZE * 0.5 + 0.5*anchors[ ele * 2]),int(INPUT_SIZE * 0.5 + 0.5*anchors[ ele * 2 + 1])), (0, 255-ele*10, 0), 2)# cv2.imwrite('./' + picName.split('.')[0] + '_saveMask13.' + picName.split('.')[1], img)# cv2.imshow('img', img)if SHOW_ALL_FLAG or FEATURE_MAP_SIZE==26:for ele in mask26:# print(ele)cv2.rectangle(img, (int(INPUT_SIZE * 0.5 - 0.5*anchors[ ele * 2]), int(INPUT_SIZE * 0.5 - 0.5*anchors[ ele * 2 + 1]) ),(int(INPUT_SIZE * 0.5 + 0.5*anchors[ ele * 2]),int(INPUT_SIZE * 0.5 + 0.5*anchors[ ele * 2 + 1]) ), (255, 255-ele*10, 0), 2)# cv2.imwrite('./' + picName.split('.')[0] + '_saveMask26.' + picName.split('.')[1], img)if SHOW_ALL_FLAG or FEATURE_MAP_SIZE==52:for ele in mask52:# print(ele)cv2.rectangle(img, (int(INPUT_SIZE * 0.5 - 0.5*anchors[ ele * 2]), int(INPUT_SIZE * 0.5 - 0.5*anchors[ ele * 2 + 1]) ),(int(INPUT_SIZE * 0.5 + 0.5*anchors[ ele * 2]),int(INPUT_SIZE * 0.5 + 0.5*anchors[ ele * 2 + 1])), (0, 255-ele*10, 255), 1)# cv2.imwrite('./' + picName.split('.')[0] + '_saveMask52.' + picName.split('.')[1], img)cv2.imwrite('./' + picName.split('.')[0] + '_allSave.' + picName.split('.')[1], img)cv2.imshow('img', img)while cv2.waitKey(1000) != 27: # loop if not get ESC.if cv2.getWindowProperty('img', cv2.WND_PROP_VISIBLE) <= 0:breakcv2.destroyAllWindows()if __name__ == '__main__':showPrioriBox()

總結

以上是生活随笔為你收集整理的yolov3 anchor 理解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。