Giter VIP home page Giter VIP logo

yolo_nano's Introduction

Introduction

YOLO nano is from this paper.

TODO

Since I'm too busy at the end of the semester, I will continue working on this project after my exams.

  • Finish a draft version of implementation
  • Add README
  • Add checkpoint support
  • Add COCO dataset support (Code still needs cleaning. I'm working on it.)
  • Add multi scale and horizontal flip transforms
  • Reconstruct the code of visualizer
  • Add val and test
  • Add VOC support
  • Test accuracy

Installation

git clone https://github.com/liux0614/yolo_nano
pip3 install -r requirements.txt

COCO

Project Structure

root/
  results/
  datasets/
    coco/
      images/
        train/
        val/
      annotation/
        instances_train2017.json
        instances_val2017.json

Train

To use COCO dataset loader, pycocotools should be installed via the following command.

pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

To train on COCO dataset:

python3 main.py --dataset_path datasets/coco/images --annotation_path datasets/coco/annotation/instances_train2017.json 
                --dataset coco --lr 0.0001 --conf_thres 0.8 --nms_thres 0.5

yolo_nano's People

Contributors

liux0614 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

yolo_nano's Issues

运行时报错中断,NameError: name 'vis' is not defined

Epoch 4/10

Traceback (most recent call last):
  File "main.py", line 108, in <module>
    val(model, val_dataloader, epoch, opt, val_logger, visualizer)
  File "/home/z/anaconda3/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 43, in decorate_no_grad
    return func(*args, **kwargs)
  File "/home/z/桌面/yolo_nano-master/val.py", line 61, in val
    vis.plot_metrics(metric_table_data, batches_done, env='main')
NameError: name 'vis' is not defined

训练出来的权重大小和参数量?

我看论文里的网络结构还是比较复杂的,对这个网络最终产生的权重文件是否真的只有4MB有些怀疑,想问您复现代码最终训练得到的权重文件大小是多少呢?

论文复现问题

请问下代码basic_layers.py中的PEP模块和EP模块的实现与论文中的结构图并不相同,少了一层expansion layer和projection layer,这里是基于什么考虑的呢?

大佬想问一下您的代码细节问题

您的YOLOLayer类里的forward函数里的targets的大小是什么呢?能给个比较详细的解释吗?我想用VOC数据集来训练,也是第一次接触YOLO,拜托了

代码要如何测试呢?

你好,我按照步骤训练了一下,虽然mAP很低,但想在测试集上跑一下,但是一直报不知名的错误,要如何测试呢,也没有输入checkpoint点的地方?

Some questions

1.One line of code is missing in yolo_nano.py,that is "out = self.pep4(out)".
2.Do any training use this code?and the test accuary compare with the paper?

Why expansion ratio is set to 1?

There's no hint in the original paper what expansion ratio is. However, since the building blocks of YOLO NANO is based on MobileNetV2. Why just use the expansion ratio of MobileNet which is just 6.?

#

Big god you good

在训练过程中报错[Errno 111] 拒绝连接

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /events (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fdef0427b70>: Failed to establish a new connection: [Errno 111] 拒绝连接',))
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fdee3a2f278>: Failed to establish a new connection: [Errno 111] 拒绝连接

sock.connect(sa) ConnectionRefusedError: [Errno 111] 拒绝连接

网络设计几点疑问

看了代码,和yolo nano论文,有几点疑问:
1,yolo最后一层应该是纯卷积吧?实现中好像是 卷积+bn+激活。
例如 out_conv10 = self.conv10(out)
2,论文中EP模块是有elementwise相加的,但是实现中发现channel不同,实际EP没有elementwise相加,是论文那边表述错了吗?

较难收敛

up主有尝试训练吗?
我用coco2017练,iou0.5,mAP0.19

Connection refused error

Hi liux0614, thanks for sharing this code. When I was trying it out with the suggested training command, I seem to be getting the following message below printed repeatedly to the error logs. Do you know what the cause might be, or if it causes any issues? Thanks for any advice!

python3 main.py --dataset_path datasets/coco/images --annotation_path datasets/coco/annotations/ --dataset coco --lr 0.0001 --conf_thres 0.8 --nms_thres 0.5 2> error.log 1> output.log &

error.log:
WARNING:root:Setting up a new session...
Traceback (most recent call last):
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/urllib3/connec
tion.py", line 157, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/urllib3/util/c
onnection.py", line 84, in create_connection
raise err
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/urllib3/util/c
onnection.py", line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/urllib3/connec
tionpool.py", line 672, in urlopen
chunked=chunked,
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/urllib3/connec
tionpool.py", line 387, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/home/henry/anaconda3/lib/python3.7/http/client.py", line 1244, in req
uest
self._send_request(method, url, body, headers, encode_chunked)
File "/home/henry/anaconda3/lib/python3.7/http/client.py", line 1290, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/home/henry/anaconda3/lib/python3.7/http/client.py", line 1239, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/henry/anaconda3/lib/python3.7/http/client.py", line 1026, in _send_output
self.send(msg)
File "/home/henry/anaconda3/lib/python3.7/http/client.py", line 966, in send
self.connect()
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/urllib3/connection.py", line 184, in connect
conn = self._new_conn()
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fdd6c5dd110>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fdd6c5dd110>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/visdom/init.py", line 548, in _send
data=json.dumps(msg),
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/requests/sessions.py", line 581, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/home/henry/yolo_nano/ynano/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fdd6c5dd110>: Failed to establish a new connection: [Errno 111] Connection refused'))
ERROR:visdom:[Errno 111] Connection refused

Repeats...

val 问题

验证模型的时候随机性的报如下错误,有遇到过没
ting Model ----
Traceback (most recent call last):
File "main.py", line 118, in
val(model, val_dataloader, epoch, opt, val_logger, visualizer)
File "/opt/conda/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 43, in decorate_no_grad
return func(*args, **kwargs)
File "/wangxiaobo_work/10-torch/yolo_nano/val.py", line 50, in val
true_positives, pred_scores, pred_labels = [np.concatenate(x, 0) for x in list(zip(*sample_matrics))]
ValueError: not enough values to unpack (expected 3, got 0)

关于模型输出

大佬,我对模型的输出值有点疑问。
detections = model.forward(images)
模型的输出detection是(1,10647,8),每一个8的前四个值是box的xywh,对吗?为什么这里的xywh会有负值呢?这个负值一点score很低会被过滤掉吗?

更改COCO类别数后报错AssertionError

我想用自己的数据集训练,于是修改了coco.names,opts.py两个文件中的类别数,修改后出现以下错误。

z@z:~/桌面/yolo_nano-master$ python3 main.py --dataset_path datasets/images --annotation_path datasets/annotation/ --dataset coco --lr 0.0001 --conf_thres 0.8 --nms_thres 0.5
------------------------ OPTIONS -----------------------------
          annotation_path: datasets/annotation/          
               batch_size: 16                            
              begin_epoch: 0                             
      checkpoint_interval: 10                            
          checkpoint_path: ./checkpoints                 
           classname_path: datasets/coco.names           
               conf_thres: 0.8                           
                  dataset: coco                          
             dataset_path: ./datasets/images             
                   device: cuda                          
                 final_lr: 0.1                           
   gradient_accumulations: 1                             
               hflip_prob: 0.5                           
               image_size: 416                           
                       lr: 0.0001                        
              manual_seed: 42                            
                    model: yolo_nano                     
                 momentum: 0.9                           
                nms_thres: 0.5                           
                  no_cuda: False                         
                 no_hflip: False                         
           no_multi_scale: False                         
            no_pad2square: False                         
                 no_train: False                         
                   no_val: False                         
                   no_vis: False                         
                no_vis_gt: False                         
             no_vis_preds: False                         
              num_classes: 2                             
               num_epochs: 20                            
              num_threads: 8                             
                optimizer: Adam                          
            print_options: True                          
             project_root: .                             
              resume_path:                               
                     test: False                         
             val_interval: 5                             
           vis_all_images: False                         
             weight_decay: 0.001                         
------------------------  END   ------------------------------

Traceback (most recent call last):
  File "main.py", line 33, in <module>
    visualizer = Visualizer(opt)
  File "/home/z/桌面/yolo_nano-master/utils/visualizer.py", line 22, in __init__
    assert len(self.class_names) == opt.num_classes
AssertionError

关于网络设计

在作者的原文中这是人机协作的网络,我看了一眼代码,你是按照论文中的图片给出的框架把网络给写死了,没有体现出这个网络的异构性,后续会继续更新吗?
我想请教下你对文中探索网络框架的算法有什么看法吗?文中描述的很模糊,就只说了是迭代生成的。
而且我对作者在文中提到种子和原型设计不是太理解,可以请教下你的看法吗?

1

some exception when training

预训练模型的问题

请问您在训练时如何解决没有预训练模型的问题?我用darknet框架训练时在没有预模型的情况下训练voc数据集loss并不会收敛。

训练阶段出现维度不匹配,还望博主给些指导

Traceback (most recent call last):
  File "main.py", line 105, in <module>
    train(model, optimizer, train_dataloader, epoch, opt, train_logger, visualizer)
  File "/media/yolo_nano-master/train.py", line 27, in train
    loss, detections = model.forward(images, targets)
  File "/media/yolo_nano-master/models/yolo_nano.py", line 134, in forward
    temp, layer_loss = self.yolo_layer52(out_conv9, targets, image_size)
  File "/home/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/media//yolo_nano-master/models/basic_layers.py", line 197, in forward
    ignore_thres=self.ignore_thres,
  File "/media/yolo_nano-master/utils/stats.py", line 303, in build_targets
    obj_mask[b, best_n, gj, gi] = 1
IndexError: index 44 is out of bounds for dimension 3 with size 44

你好博主,我在利用你的模型训练的时候中间出现这个错误,我检测的类别是3类,我查看了一下,但是没有看出哪里又错误,还望博主有时间的情况下,给些指导,感谢!

关于测试结果的几个问题

@liux0614 麻烦问下,您实际的测试结果怎样的?我经训练后(默认20Epoch,Total loss 9.56)测试,有几个问题,麻烦问下看是哪里设置有问题:
1、图片中大的物体基本上都无法检出,小物体可以检测出来;
2、检测出的物体分类有问题,大部分是错误分类,标记为Person;
3、检测出的BBox定位精度不高,和物体实际bbox有一定偏差;

麻烦问下,这几个问题是因为训练的迭代次数少还是有其他原因,这几个问题麻烦问下,怎样解决,谢谢!

预测框类别全是人!

在训练的过程中,虽然损失函数的值在下降,但是可视化界面的预测框类别却全是人,大部分时间是没有框的,不知道这是为什么,我该怎么修改。

用于其他数据集

能否在这个代码基础上,对其他数据集fine-tuning呢?膜拜大佬,求大佬更新

在COCO上实现模型可能得不到较好的结果

对于NAS搜索得到的结构,应该是有一定的对于数据集的依赖性,甚至对VOC有一定的过拟合,如果想复现论文结果的话,建议作者还是再VOC2007+VOC2012上训练,并在VOC2007上测试,能得到相当的结果后,再考虑测试该模型在不同数据集上的泛化能力==

License

Thank you for the implementation! I would be glad to source it for an own project, but so far could not do it "legally". Would you mind adding a license to it, so it would be clear if you encourage/discourage derivatives, enhancements, etc?

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.