GithubHelp home page GithubHelp logo

dog-qiuqiu / yolo-fastestv2 Goto Github PK

View Code? Open in Web Editor NEW
784.0 16.0 191.0 11.94 MB

:zap: Based on Yolo's low-power, ultra-lightweight universal target detection algorithm, the parameter is only 250k, and the speed of the smart phone mobile terminal can reach ~300fps+

Python 100.00%

yolo-fastestv2's People

Contributors

dog-qiuqiu avatar rockcarry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yolo-fastestv2's Issues

batch-size设置过大了么这个报错

ConnectionResetError: [Errno 104] Connection reset by peer

batch-size设置过大了么这个报错
以前设置600没事这次为啥32都报错 设置成26才没报错 = =

low precision and and recall

Hello

Im training with only one class from coco dataset, data file is standar only changes anchors and classes to 1

[name]
model_name=coco

[train-configure]
epochs=300
steps=150,250
batch_size=128
subdivisions=1
learning_rate=0.001

[model-configure]
pre_weights=model/backbone/backbone.pth
classes=1
width=352
height=352
anchor_num=3
anchors=8.54,20.34, 25.67,59.99, 52.42,138.38, 103.52,235.28, 197.43,103.53, 238.02,287.40

[data-configure]
train=coco_person/train.txt
val=coco_person/val.txt
names=data/coco.names

I get an AP of 0.41 but with low precision 0.53 and recall of 0.41 that makes that model prediction has lots of false positives.

Why im getting that low precision and recall?

PD. i checked bbox annotations and are correct

Thanks!

No module named 'utils'

(yoloall) gy@server:/mount_sdc/work_zp/Train/yoloall/model_zoo/YoloFastestV2$ pip install python-utils
Collecting python-utils
Downloading python_utils-2.5.6-py2.py3-none-any.whl (12 kB)
Collecting six
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, python-utils
Successfully installed python-utils-2.5.6 six-1.16.0
(yoloall) gy@server:
/mount_sdc/work_zp/Train/yoloall/model_zoo/YoloFastestV2$ python3 test.py --data data/coco.data --weights modelzoo/coco2017-0.241078ap-model.pth --img img/000139.jpg
Traceback (most recent call last):
File "test.py", line 8, in
import utils.utils
ModuleNotFoundError: No module named 'utils'

在树莓派中跑demo无结果框

您好,我根据自己的数据集训练了模型并转换成功,在x86_64中跑demo,可以正确出结果.
但是同样的模型拷至树莓派4B,编译demo后,拿同样的图测试,不出结果,什么框也没有,请问到树莓派上是否还需要改动什么?

有关类别的指定

Hi qiuqiu,
请教一下,我目前想训练一个只侦测person的模型,有几个问题想确认一下:
1.预先准备的.txt档,第一列是类别,person在coco dataset中,id是1,所以.txt的第一列也是1吗?
2.coco.data中, classes是设定为1吗?
3.我设定txt档第一列是1,coco.data中classes设定为1,coco.names只有person,在训练中,发现cls loss始终是0,total loss看起来是在逐渐缩小.这个现象正常否?

麻烦指点一下,谢谢!!

convert pytorch to onnx format

I am trying to rebuild and use my own trained model on this OpenCV version of yolofastestv2:
https://github.com/hpc203/yolo-fastestv2-opencv
But I got the following error message:

Traceback (most recent call last):
  File "E:\MyWork\Yolo-FastestV2\dnn.py", line 112, in <module>
    outputs = model.detect(srcimg)
  File "E:\MyWork\Yolo-FastestV2\dnn.py", line 91, in detect
    outputs[top:top + length, 0:2] = (outs[row_ind:row_ind + length,
ValueError: operands could not be broadcast together with shapes (1,2,22,95) (484,2) 

My understanding is the model output is two different scale of feature maps, but the OpenCV version implementation only accept one. So does anyone know how to concatenate two features maps when converting the format from PyTorch to onnx?

Anchor Number

I reduce the anchor number from 3 to 2, and there is a problem during training (evaluation):

anchor_boxes[:, :, :, :2] = ((r[:, :, :, :2].sigmoid() * 2. - 0.5) + grid) * stride

RuntimeError: The size of tensor a (2) must match the size of tensor b (3) at non-singleton dimension 3

The model configure is:

[model-configure]
pre_weights=None
classes=7
width=320
height=320
anchor_num=2
anchors=10.54,9.51, 45.60,40.45, 119.62,95.06, 253.71,138.37

IndexError: too many indices for tensor of dimension 1

First of all thanks for your code.
I executed the following code and reported an error.
python3 train.py --data train/mosaic/train.data

Traceback (most recent call last):
File "train.py", line 138, in
_, _, AP, _ = utils.utils.evaluation(val_dataloader, cfg, model, device)
File "/home/zsf/work/Yolo-FastestV2/utils/utils.py", line 372, in evaluation
labels += targets[:, 1].tolist()
IndexError: too many indices for tensor of dimension 1

I don't know what incurs this error.I hope someone can give me some advice to solve this problem.Thanks a lot.

GPU训练

请问大佬,能否使用GPU训练模型?我的torch.cuda.is_available()为True,代码指定GPU这一行 device = torch.device("cuda" if torch.cuda.is_available() else "cpu")即指定GPU,但当训练时,nvidia-smi查看GPU利用率是为0,请问博主是我操作上忘记某个开启GPU的开关了吗?还请大佬提示

onnx2ncnn error Gather not supported yet!

(base) ~/Yolo-FastestV2$ python pytorch2onnx.py --data ./data/coco.data --weights modelzoo/coco2017-epoch-0.235624ap-model.pth
load param...
/home/pc/Yolo-FastestV2/model/backbone/shufflenetv2.py:59: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert (num_channels % 4 == 0)

./onnx2ncnn model.onnx fast.param fast.bin
Gather not supported yet!

axis=0

Gather not supported yet!

axis=0

Gather not supported yet!

axis=0

Gather not supported yet!

无法用torch.nn.parallel.DistributedDataParallel进行分布式训练?

尝试用DistributedDataParallel做分布式训练,会出问题,有时在total_loss.backward()的时候hang住,有时在
preds = model(imgs)这句报错:
RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your
module has parameters that were not used in producing loss. Since find_unused_parameters=True is enabled, this likely means that
not all forward outputs participate in computing loss. You can fix this by making sure all forward function outputs participat e in calculating loss.
If you already have done the above, then the distributed data parallel module wasn't able to locate the output tensors in the return
value of your module's forward function. Please include the loss function and the structure of the return value of forward of your module when reporting this issue (e.g. list, dict, iterable).
Parameters which did not receive grad for rank 0: fpn.reg_head_3.block.9.bias, fpn.reg_head_3.block.9.weight, fpn.reg_head_3.block.8.weight, fpn.reg_head_3.block.6.bias, fpn.reg_head_3.block.6.weight, fpn.reg_head_3.block.5.weight, fpn.reg_head_3.block.4.bias, fpn.reg_head_3.block.4.weight, fpn.reg_head_3.block.0.weight, fpn.reg_head_3.block.1.weight, fpn.reg_head_3.block.1.bias, fpn.reg_head_3.block.3.weight

有没有遇到过这个问题?

torch.max_pool2d

(yolofast) root@7c295650a9e8:/work/work_zp/yolo-fastestv2# python3 test.py --data data/coco.data --weights modelzoo/coco2017-0.241078ap-model.pth --img img/000139.jpg
load param...
/work/anaconda3/envs/yolofast/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /pytorch/c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
forward time:14.529923ms

Where are weights and options saved after training?

The question: when I did 'Train' part in 'How to use' instruction, where are weights and whole model saved after training and how could I launch real-time detection?

Comment: I am noob in ML, so I want to train this model and use it in Raspberry Pi real-time detection. I've already trained YoloV3 model and there are methods that give you ability to see best params of trained model, her weight, etc. There I could also launch real-time detection with my web-cam. But with your neural-network I can't really know if I trained the model and where weights and itsself placed AND also can't launch real-time object detection, only detection with test.py that only takes 1 picture.

Final: Your neural-network is a good chance for real-time object detection with GOOD FPS on Raspberry without Google Corals, NCS and other things that has a high money price to buy. So PLEASE, can somebody help me in this? I didn't find anything at youtube nor google. : (

person框不完整

Hi qiuqiu,

请教一下。我用code训练coco的person一个类别,训练后的模型看起来效果还不错,但有一个比较大的问题是,有些情形下,bbox对person看起来没有完整的框住,比如人高举手,或者伸展四肢,就会有这种问题。我的疑问是,对此类问题,除了增加适当的训练数据,模型本身有什么可以值得优化的吗?麻烦指点一下,谢谢!!

ncnn加载模型文件抛异常

大神你好,请问ncnn的版本是多少?我在window10下用ncnn-20210720-windows-vs2019-shared的ncnn库加载官方提供的yolo-fastestv2-opt.bin和yolo-fastestv2-opt.param模型抛异常,会和ncnn的版本有关系么?

RuntimeError

训练时候,提示这个错误。
RuntimeError: Pin memory thread exited unexpectedly

onnx的转化与读取

作者你好,我在训练完模型后将其转化为onnx,运行pytoch2onnx后便得到了yolo-fastestv2.onnx。为了验证onnx是否转成功,我利用该转换后的.onnx去读取图片:

net = cv2.dnn.readNetFromONNX("yolo-fastestv2.onnx")
image = cv2.imread("6826.img")
blob = cv2.dnn.blobFromImage(image)
net.setInput(blob)
out = net.forward()

报错显示cv2.error in function cv::dnn::computeShapeByReshapeMask
然而我用同事转换成功的resnet18.onnx却不会报错

想要请教你遇到过这个问题吗?该如何解决呢?

测试样例,没找到生成图片文件

下载源码,运行如下命令:
python3 test.py --data data/coco.data --weights modelzoo/coco2017-0.241078ap-model.pth --img img/000139.jpg

却没找到test_result.png,指导一下是什么原因?多谢

获得新的预训练模型

大佬。请问更改了模型后想要自己重新得到预训练模型,是不是得在imagenet数据集上重新训练,然后去除不需要的权重呢,能说明一下获得的步骤吗

FLOPS

大佬想问一下,FLOPS怎么知道的

您好,出现下面这个警告该如何修改代码里面的内容呢?torch文档说换某一步骤的内容,但不太清楚如何更换。

UserWarning: Detected call of lr_scheduler.step(() before optimizer.step(). In PyTorch 1.1.0 and later, you should call them in the opposite order: optimizer.step() before lr_scheduler.step(). a
Failure to do this will result in PyTorch skipping the first value of the learning rate schedule. See more details at https://pytorch.org/docs/stable/opt.im.html#how-to-adjust-learning-rate

Note for handling training data with negative or null labels

First, @dog-qiuqiu you have done excellent work in V2. The tooling (scripts, etc) and performance are a big improvement over V1. Thank you so much for your work here!

This is a note for other users who may have encountered this error, and could be useful for the FAQ:

In Darknet I was able to have image data in my training set that had an empty .txt file, which is to say one without any labels defined. I had erroneously assumed providing null or negative cases would help training and model accuracy for my use case. This produces this error in train.py:

RuntimeError: Sizes of tensors must match except in dimension 1. Got 0 and 1 (The offending index is 0)

The solution is to remove the training images which have no labels. Yolo models have no benefit from negative training, as explained in this SO answer here

How to laod pretrained model

I want to load the pretrained coco model when training. the coco ona has 80 classes. but mu one has only 2 classes.

so i the model created by Detector, the input parameter 'classes' is 2. so the model failed to load pretrained model. because the output tensor is not the same.

then, how to support laoding pretrained model?

missing .txt label file while executing evaluate.py

Some of my coco data occur label missing problem(images exist, but label not).

I download the coco2017 dataset from the official. However, this dataset exist some missing labels.

Does anyone have the coco dataset or script which follows the author-provided format in README.md and no missing labels occur?

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.