This commit is contained in:
we0091234
2023-03-20 20:18:04 +08:00
parent a1fefac249
commit 309fe0ced6
8 changed files with 61 additions and 10 deletions

2
.gitignore vendored
View File

@@ -18,6 +18,8 @@ pretrained_model/
cfg1/
test_imgs/
weixian/
moto/
pic/
# 不忽略下面指定的文件类型
!*.cpp
!*.h

View File

@@ -0,0 +1,47 @@
# parameters
nc: 6 # number of classes
nkpt: 0 # number of keypoints
depth_multiple: 1.0 # model depth multiple
width_multiple: 1.0 # layer channel multiple
anchors:
- [ 19,27, 44,40, 38,94 ] # P3/8
- [ 96,68, 86,152, 180,137 ] # P4/16
- [ 140,301, 303,264, 238,542 ] # P5/32
- [ 436,615, 739,380, 925,792 ] # P6/64
# custom backbone
backbone:
# [from, number, module, args]
[ [ -1, 1, StemBlock, [32, 3, 2] ], # 0-P2/4
[ -1, 1, Shuffle_Block, [96, 2]], # 1-P3/8
[ -1, 3, Shuffle_Block, [96, 1]], # 2
[ -1, 1, Shuffle_Block, [192, 2]], # 3-P4/16
[ -1, 7, Shuffle_Block, [192, 1]], # 4
[ -1, 1, Shuffle_Block, [384, 2]], # 5-P5/32
[ -1, 3, Shuffle_Block, [384, 1]], # 6
[ -1, 1, SPPF, [384, 5]],
]
# v5lite-e head
head:
[ [ -1, 1, Conv, [96, 1, 1]],
[ -1, 1, nn.Upsample, [ None, 2, 'nearest']],
[[ -1, 4], 1, Concat, [1]], # cat backbone P4
[ -1, 1, DWConvblock, [96, 3, 1]], # 11
[ -1, 1, Conv, [96, 1, 1]],
[ -1, 1, nn.Upsample, [ None, 2, 'nearest']],
[[ -1, 2], 1, Concat, [1]], # cat backbone P3
[ -1, 1, DWConvblock, [96, 3, 1] ], # 15 (P3/8-small)
[-1, 1, DWConvblock, [96, 3, 2]],
[[ -1, 12], 1, ADD, [1]], # cat head P4
[ -1, 1, DWConvblock, [96, 3, 1]], # 18 (P4/16-medium)
[ -1, 1, DWConvblock, [96, 3, 2]],
[[ -1, 8], 1, ADD, [1]], # cat head P5
[ -1, 1, DWConvblock, [96, 3, 1]], # 21 (P5/32-large)
[[ 15, 18, 21], 1, IKeypoint, [nc, anchors, nkpt]], # Detect(P3, P4, P5)
]

View File

@@ -8,8 +8,8 @@
# train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]
train: /mnt/Gpan/Mydata/pytorchPorject/datasets/ccpd/train_detect
val: /mnt/Gpan/Mydata/pytorchPorject/datasets/ccpd/val_detect/
train: /mnt/Gu/trainData/Detect/plate_detect/train_detect
val: /mnt/Gu/trainData/Detect/plate_detect/val_detect
#val: /ssd_1t/derron/yolov5-face/data/widerface/train/ # 4952 images
# number of classes

View File

@@ -30,7 +30,9 @@ def order_points(pts): #关键点按照(左上,右上,右下,左下)
def four_point_transform(image, pts): #透视变换
rect = order_points(pts)
# rect = order_points(pts)
rect=pts.astype("float32")
(tl, tr, br, bl) = rect
widthA = np.sqrt(((br[0] - bl[0]) ** 2) + ((br[1] - bl[1]) ** 2))
widthB = np.sqrt(((tr[0] - tl[0]) ** 2) + ((tr[1] - tl[1]) ** 2))
@@ -145,14 +147,14 @@ def draw_result(orgimg,dict_list):
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--detect_model', nargs='+', type=str, default='weights/yolov7-lite-s.pt', help='model.pt path(s)')
parser.add_argument('--rec_model', type=str, default='weights/plate_rec.pth', help='model.pt path(s)')
parser.add_argument('--rec_model', type=str, default='weights/plate_rec_small.pth', help='model.pt path(s)')
parser.add_argument('--source', type=str, default='imgs', help='source') # file/folder, 0 for webcam
# parser.add_argument('--img-size', nargs= '+', type=int, default=640, help='inference size (pixels)')
parser.add_argument('--img_size', type=int, default=640, help='inference size (pixels)')
parser.add_argument('--output', type=str, default='result', help='source')
parser.add_argument('--kpt-label', type=int, default=4, help='number of keypoints')
device =torch.device("cuda" if torch.cuda.is_available() else "cpu")
# device = torch.device("cpu")
# device =torch.device("cuda" if torch.cuda.is_available() else "cpu")
device = torch.device("cpu")
opt = parser.parse_args()
print(opt)
model = attempt_load(opt.detect_model, map_location=device)

View File

@@ -26,7 +26,7 @@ from utils.torch_utils import select_device
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--weights', type=str, default='./yolov5s.pt', help='weights path')
parser.add_argument('--img-size', nargs='+', type=int, default=[640, 640], help='image size') # height, width
parser.add_argument('--img-size', nargs='+', type=int, default=[320, 320], help='image size') # height, width
parser.add_argument('--batch-size', type=int, default=1, help='batch size')
parser.add_argument('--grid', action='store_true', help='export Detect() layer grid')
parser.add_argument('--device', default='cpu', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')

View File

@@ -232,10 +232,10 @@ def draw_result(orgimg,dict_list):
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--detect_model',type=str, default=r'weights/plate_detect.onnx', help='model.pt path(s)') #检测模型
parser.add_argument('--detect_model',type=str, default=r'runs/train/yolov714/weights/best.onnx', help='model.pt path(s)') #检测模型
parser.add_argument('--rec_model', type=str, default='weights/plate_rec.onnx', help='model.pt path(s)')#识别模型
parser.add_argument('--image_path', type=str, default=r'imgs', help='source')
parser.add_argument('--img_size', type=int, default=640, help='inference size (pixels)')
parser.add_argument('--image_path', type=str, default=r'pic', help='source')
parser.add_argument('--img_size', type=int, default=320, help='inference size (pixels)')
parser.add_argument('--output', type=str, default='result', help='source')
opt = parser.parse_args()
file_list = []

Binary file not shown.

BIN
weights/plate_rec_small.pth Normal file

Binary file not shown.