we0091234 / chinese_license_plate_detection_recognition Goto Github PK
View Code? Open in Web Editor NEWyolov5 车牌检测 车牌识别 中文车牌识别 检测 支持12种中文车牌 支持双层车牌
License: GNU General Public License v3.0
yolov5 车牌检测 车牌识别 中文车牌识别 检测 支持12种中文车牌 支持双层车牌
License: GNU General Public License v3.0
在face_datasets.py
文件中getitem方法
获取关键点信息时为什么后面要(np.array(x[:, 5] > 0, dtype=np.int32) - 1)
labels[:, 5] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 5] + pad[0]) + (
np.array(x[:, 5] > 0, dtype=np.int32) - 1)
labels[:, 6] = np.array(x[:, 6] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 6] + pad[1]) + (
np.array(x[:, 6] > 0, dtype=np.int32) - 1)
labels[:, 7] = np.array(x[:, 7] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 7] + pad[0]) + (
np.array(x[:, 7] > 0, dtype=np.int32) - 1)
labels[:, 8] = np.array(x[:, 8] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 8] + pad[1]) + (
np.array(x[:, 8] > 0, dtype=np.int32) - 1)
labels[:, 9] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 9] + pad[0]) + (
np.array(x[:, 9] > 0, dtype=np.int32) - 1)
labels[:, 10] = np.array(x[:, 5] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 10] + pad[1]) + (
np.array(x[:, 10] > 0, dtype=np.int32) - 1)
labels[:, 11] = np.array(x[:, 11] > 0, dtype=np.int32) * (ratio[0] * w * x[:, 11] + pad[0]) + (
np.array(x[:, 11] > 0, dtype=np.int32) - 1)
labels[:, 12] = np.array(x[:, 12] > 0, dtype=np.int32) * (ratio[1] * h * x[:, 12] + pad[1]) + (
np.array(x[:, 12] > 0, dtype=np.int32) - 1)
您好!我按照您在https://github.com/we0091234/Chinese_license_plate_detection_recognition/tree/main/readme所列的步骤中训练自己模型时,发现出现错误WARN:[email protected]] global loadsave.cpp:248 cv:[ WARN:[email protected]] global loadsave.cpp:248 cv::findDecoder imread_('/mnt/Gpan/Mydata/pytorchPorject/datasets/cc[::findDecoder imread_('/mnt/Gpan/Mydata/pytorchPorject/datasets/ccpd/train_car_plate/train_detect/CCPD/00336805555555-Traceback (most recent call last):
我估计应该是路径设置的问题,但我实在是找不到这个是在哪里改的了,特此想请教一下您!万分感谢!
when i export_torchscipt. It reports
local/lib/python3.6/site-packages/torch/_tensor.py:575: UserWarning: floor_divide is deprecated, and will be removed in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values.
To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor'). (Triggered internally at /pytorch/aten/src/ATen/native/BinaryOps.cpp:467.)
return torch.floor_divide(self, other)
can you tell me your training pytroch version? and have you trained yolov5s. if so, can you public the model. thanks
将来是否考虑支持双层或者多层牌都出牌?
rt,似乎没有找到代码,求~
给定训练好的检测模型,加载该模型,并给出检测的统计结果mAP
您好,感谢您的优质项目。
我有一个问题想请教您:请问您训练检测模型时,使用了预训练权重了吗?
Traceback (most recent call last):
File "D:\huohu\Chinese_license_plate_detection_recognition-main\Chinese_license_plate_detection_recognition-main\train.py", line 520, in
train(hyp, opt, device, tb_writer, wandb)
File "D:\huohu\Chinese_license_plate_detection_recognition-main\Chinese_license_plate_detection_recognition-main\train.py", line 187, in train
dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt,
File "D:\huohu\Chinese_license_plate_detection_recognition-main\Chinese_license_plate_detection_recognition-main\utils\face_datasets.py", line 62, in create_dataloader
dataset = LoadFaceImagesAndLabels(path, imgsz, batch_size,
File "D:\huohu\Chinese_license_plate_detection_recognition-main\Chinese_license_plate_detection_recognition-main\utils\face_datasets.py", line 164, in init
labels, shapes = zip(*cache.values())
ValueError: not enough values to unpack (expected 2, got 0)
demo里面的模型无法识别到两个车牌,只能识别到其中一个。是我模型用错了吗?
感谢开源,请问有危险品车辆数据集吗
File "E:\work\code\Car_recognition-master\train.py", line 521, in
train(hyp, opt, device, tb_writer, wandb)
File "E:\work\code\Car_recognition-master\train.py", line 291, in train
loss, loss_items = compute_loss(pred, targets.to(device), model) # loss scaled by batch_size
File "E:\work\code\Car_recognition-master\utils\loss.py", line 163, in compute_loss
lcls += BCEcls(ps[:, 13:], t) # BCE
File "E:\soft1\conda\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "E:\soft1\conda\lib\site-packages\torch\nn\modules\loss.py", line 720, in forward
return F.binary_cross_entropy_with_logits(input, target,
File "E:\soft1\conda\lib\site-packages\torch\nn\functional.py", line 3162, in binary_cross_entropy_with_logits
return torch.binary_cross_entropy_with_logits(input, target, weight, pos_weight, reduction_enum)
File "E:\soft1\conda\lib\site-packages\torch\fx\traceback.py", line 57, in format_stack
return traceback.format_stack()
(Triggered internally at C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\autograd\python_anomaly_mode.cpp:119.)
Variable.execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
0%| | 0/24 [00:00<?, ?it/s]
Traceback (most recent call last):
File "E:\work\code\Car_recognition-master\train.py", line 521, in
train(hyp, opt, device, tb_writer, wandb)
File "E:\work\code\Car_recognition-master\train.py", line 296, in train
scaler.scale(loss).backward()
File "E:\soft1\conda\lib\site-packages\torch_tensor.py", line 487, in backward
torch.autograd.backward(
File "E:\soft1\conda\lib\site-packages\torch\autograd_init.py", line 197, in backward
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [30, 2]], which is output 0 of AsStridedBackward0, is at
version 4; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
def jaccard_diou(box_a, box_b, iscrowd:bool=False):
use_batch = True
if box_a.dim() == 2:
use_batch = False
box_a = box_a[None, ...]
box_b = box_b[None, ...]
inter = intersect(box_a, box_b)
area_a = ((box_a[:, :, 2]-box_a[:, :, 0]) *
(box_a[:, :, 3]-box_a[:, :, 1])).unsqueeze(2).expand_as(inter) # [A,B]
area_b = ((box_b[:, :, 2]-box_b[:, :, 0]) *
(box_b[:, :, 3]-box_b[:, :, 1])).unsqueeze(1).expand_as(inter) # [A,B]
union = area_a + area_b - inter
x1 = ((box_a[:, :, 2]+box_a[:, :, 0]) / 2).unsqueeze(2).expand_as(inter)
y1 = ((box_a[:, :, 3]+box_a[:, :, 1]) / 2).unsqueeze(2).expand_as(inter)
x2 = ((box_b[:, :, 2]+box_b[:, :, 0]) / 2).unsqueeze(1).expand_as(inter)
y2 = ((box_b[:, :, 3]+box_b[:, :, 1]) / 2).unsqueeze(1).expand_as(inter)
t1 = box_a[:, :, 1].unsqueeze(2).expand_as(inter)
b1 = box_a[:, :, 3].unsqueeze(2).expand_as(inter)
l1 = box_a[:, :, 0].unsqueeze(2).expand_as(inter)
r1 = box_a[:, :, 2].unsqueeze(2).expand_as(inter)
t2 = box_b[:, :, 1].unsqueeze(1).expand_as(inter)
b2 = box_b[:, :, 3].unsqueeze(1).expand_as(inter)
l2 = box_b[:, :, 0].unsqueeze(1).expand_as(inter)
r2 = box_b[:, :, 2].unsqueeze(1).expand_as(inter)
cr = torch.max(r1, r2)
cl = torch.min(l1, l2)
ct = torch.min(t1, t2)
cb = torch.max(b1, b2)
D = (((x2 - x1)**2 + (y2 - y1)**2) / ((cr-cl)**2 + (cb-ct)**2 + 1e-7))
out = inter / area_a if iscrowd else inter / (union + 1e-7) - D ** 0.7
return out if use_batch else out.squeeze(0)
请问下有带关键点的标注工具吗
可以支持下ncnn的导出吗
你好:
这个 repo 很好啊!
我的问题:
1.不可见关键点如何处理的?
2. 推理只能得到 bbox 里面的关键点吗,如果关键点在 bbox 外可以检到吗?
label x y w h pt1x pt1y pt2x pt2y pt3x pt3y pt4x pt4y
您好我看这个项目的label是这个格式的,我想问一下如果我用的是labelimg的标注工具,只提供label x y w h,这五个值,是否可以训练,运行train.py文件???急急急
比如即检测车、也检测车牌、同时仅回归车牌的4个关键点。
感谢你的开源和你优秀的工作,请问后续有模型训练数据集的示例吗
label x y w h pt1x pt1y pt2x pt2y pt3x pt3y pt4x pt4y
原本的数据是labelme标注的,是图片和标签,图片是jpg格式,标签是json结尾的格式。我自己转换成了 yolov5的格式,例子如下
0 0.4583984374999998 0.14062499999999992 0.39101562499999987 0.15069444444444435。
请问你们的格式是怎么转换的
另外还有个bug,
Scanning '/app/dataset/fourth_project/plate_number/plate_dataset_1/labels/train' for images and labels... 1305 found, 0 missing, 0 empty, 1305 corrupted: 100%|██████████| 1305/1305 [00:39<00:00, 32.67it/s]
New cache created: /app/dataset/fourth_project/plate_number/plate_dataset_1/labels/train.cache
Scanning '/app/dataset/fourth_project/plate_number/plate_dataset_1/labels/train.cache' for images and labels... 1305 found, 0 missing, 0 empty, 1305 corrupted: 100%|██████████| 1305/1305 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/anaconda3/envs/py_37/lib/python3.7/contextlib.py", line 130, in exit
self.gen.throw(type, value, traceback)
File "/app/plate_number/Chinese_license_plate_detection_recognition-main/utils/torch_utils.py", line 32, in torch_distributed_zero_first
yield
File "/app/plate_number/Chinese_license_plate_detection_recognition-main/utils/face_datasets.py", line 72, in create_dataloader
image_weights=image_weights,
File "/app/plate_number/Chinese_license_plate_detection_recognition-main/utils/face_datasets.py", line 166, in init
labels, shapes = zip(*cache.values())
ValueError: not enough values to unpack (expected 2, got 0)
这cache的值是什么
如题
如题!
感谢开源,非常非常好用的库,识别率很高。
想问一下,这个库的识别过程有置信度的值么?
请问下这个支持视频流吗?老哥
(carbase) root@kfcs-Stad:/data/Chinese_license_plate_detection_recognition-main# python3 train.py --data data/widerface.yaml --cfg models/yolov5n-0.5.yaml --weights weights/plate_detect.pt --epoch 120
YOLOv5 torch 2.0.1+cu117 CPU
Namespace(adam=False, batch_size=32, bucket='', cache_images=False, cfg='models/yolov5n-0.5.yaml', data='data/widerface.yaml', device='cpu', epochs=120, evolve=False, exist_ok=False, global_rank=-1, hyp='data/hyp.scratch.yaml', image_weights=False, img_size=[640, 640], local_rank=-1, log_artifacts=False, log_imgs=16, multi_scale=True, name='exp', noautoanchor=False, nosave=False, notest=False, project='runs/train', rect=False, resume=False, save_dir='runs/train/exp4', single_cls=False, sync_bn=False, total_batch_size=32, weights='weights/plate_detect.pt', workers=1, world_size=1)
Start Tensorboard with "tensorboard --logdir runs/train", view at http://localhost:6006/
Hyperparameters {'lr0': 0.01, 'lrf': 0.2, 'momentum': 0.937, 'weight_decay': 0.0005, 'warmup_epochs': 3.0, 'warmup_momentum': 0.8, 'warmup_bias_lr': 0.1, 'box': 0.05, 'cls': 0.5, 'landmark': 0.005, 'cls_pw': 1.0, 'obj': 1.0, 'obj_pw': 1.0, 'iou_t': 0.2, 'anchor_t': 4.0, 'fl_gamma': 0.0, 'hsv_h': 0.015, 'hsv_s': 0.7, 'hsv_v': 0.4, 'degrees': 0.0, 'translate': 0.1, 'scale': 0.5, 'shear': 0.5, 'perspective': 0.0, 'flipud': 0.0, 'fliplr': 0.5, 'mosaic': 0.5, 'mixup': 0.0}
Overriding model.yaml nc=1 with nc=2
from n params module arguments
0 -1 1 2336 models.common.StemBlock [3, 16, 3, 2]
1 -1 1 2768 models.common.ShuffleV2Block [16, 64, 2]
2 -1 3 7584 models.common.ShuffleV2Block [64, 64, 1]
3 -1 1 14080 models.common.ShuffleV2Block [64, 128, 2]
4 -1 7 64064 models.common.ShuffleV2Block [128, 128, 1]
5 -1 1 52736 models.common.ShuffleV2Block [128, 256, 2]
6 -1 3 104064 models.common.ShuffleV2Block [256, 256, 1]
7 -1 1 16512 models.common.Conv [256, 64, 1, 1]
8 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
9 [-1, 4] 1 0 models.common.Concat [1]
10 -1 1 27008 models.common.C3 [192, 64, 1, False]
11 -1 1 4224 models.common.Conv [64, 64, 1, 1]
12 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
13 [-1, 2] 1 0 models.common.Concat [1]
14 -1 1 22912 models.common.C3 [128, 64, 1, False]
15 -1 1 36992 models.common.Conv [64, 64, 3, 2]
16 [-1, 11] 1 0 models.common.Concat [1]
17 -1 1 22912 models.common.C3 [128, 64, 1, False]
18 -1 1 36992 models.common.Conv [64, 64, 3, 2]
19 [-1, 7] 1 0 models.common.Concat [1]
20 -1 1 22912 models.common.C3 [128, 64, 1, False]
21 [14, 17, 20] 1 8775 models.yolo.Detect [2, [[4, 5, 8, 10, 13, 16], [23, 29, 43, 55, 73, 105], [146, 217, 231, 300, 335, 433]], [64, 64, 64]]
/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
Model Summary: 333 layers, 446871 parameters, 446871 gradients, 1.6 GFLOPS
Transferred 498/500 items from weights/plate_detect.pt
Optimizer groups: 85 .bias, 85 conv.weight, 82 other
Scanning '/data/train_data/CRPD_TRAIN.cache' for images and labels... 3137 found, 0 missing, 4 empty, 0 corrupted: 100%|█████████████████████████████████████████████████████████████████████████████████████| 3137/3137 [00:00<?, ?it/s]
Scanning '/data/val_detect/blue.cache' for images and labels... 5946 found, 0 missing, 0 empty, 0 corrupted: 100%|███████████████████████████████████████████████████████████████████████████████████████████| 5946/5946 [00:00<?, ?it/s]
Plotting labels...
/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/seaborn/axisgrid.py:118: UserWarning: The figure layout has changed to tight
self._figure.tight_layout(*args, **kwargs)
autoanchor: Analyzing anchors... anchors/target = 2.73, Best Possible Recall (BPR) = 1.0000
Image sizes 640 train, 640 test
Using 1 dataloader workers
Logging results to runs/train/exp4
Starting training for 120 epochs...
Epoch gpu_mem box obj cls landmark total targets img_size
0%| | 0/99 [00:00<?, ?it/s]/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/autograd/init.py:200: UserWarning: Error detected in BinaryCrossEntropyWithLogitsBackward0. Traceback of forward call that caused the error:
File "train.py", line 522, in
train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 291, in train
loss, loss_items = compute_loss(pred, targets.to(device), model) # loss scaled by batch_size
File "/data/Chinese_license_plate_detection_recognition-main/utils/loss.py", line 163, in compute_loss
lcls += BCEcls(ps[:, 13:], t) # BCE
File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 720, in forward
return F.binary_cross_entropy_with_logits(input, target,
File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/nn/functional.py", line 3165, in binary_cross_entropy_with_logits
return torch.binary_cross_entropy_with_logits(input, target, weight, pos_weight, reduction_enum)
(Triggered internally at ../torch/csrc/autograd/python_anomaly_mode.cpp:114.)
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
0%| | 0/99 [00:02<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 522, in
train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 296, in train
scaler.scale(loss).backward()
File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/_tensor.py", line 487, in backward
torch.autograd.backward(
File "/usr/local/anaconda3/envs/carbase/lib/python3.8/site-packages/torch/autograd/init.py", line 200, in backward
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [204, 2]], which is output 0 of AsStridedBackward0, is at version 4; expected version 0 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
WARNING: Ignoring corrupted image and/or label ***** labels require 13 columns each
报了好多这样的警告出来,这是怎么回事呀?该怎么解决呢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.