heyongxin233 / YOLO-Pruning-RKNN

Easy Training Official YOLOv8、YOLOv7、YOLOv6、YOLOv5 and Prune all_model using Torch-Pruning!
48 stars 6 forks source link

reduce the number of parameters by 75% without losing any accuracy! #1

Open Tim5Tang opened 10 months ago

Tim5Tang commented 10 months ago

能否分享一下裁剪网络3/4,还没有掉精度的日志

heyongxin233 commented 10 months ago

使用torch-pruning(https://github.com/VainF/Torch-Pruning) pruner = tp.pruner.MagnitudePruner( self.model, example_inputs, importance=tp.importance.MagnitudeImportance(p=2), # L2 norm pruning, iterative_steps=self.prune_iterative_steps, pruning_ratio=self.prune_ratio, ignored_layers=ignored_layers, ) pruner.step() 可以这样对模型剪枝,整个剪枝代码我已经集成进我的github中了,你可以先运行train.py,得到没有剪枝但训练好的模型,然后运行prune.py便可以在基本上不损失精度的情况下提升超过一半的速度

Tim5Tang commented 10 months ago

谢谢告知方法,我试试看

mozhuqin commented 6 months ago

您好,我想知道,咱们的剪枝方法是参考哪篇论文,或者是您想到的,有相应的文档嘛,小弟想要拜读一下

xiaoshuomin commented 6 months ago

@heyongxin233 我把prune.py中的model = YOLO('yolov8m.yaml')替换为model = YOLO('yolov8m.pt'),想从已经训练好的模型进行剪枝,但是从运行结果来看精度掉了很多,仿佛是从头开始训练一样,你可以提供这个项目更详细的使用手册吗?