{"id":13788728,"url":"https://github.com/ethanhe42/channel-pruning","last_synced_at":"2025-05-16T03:05:56.848Z","repository":{"id":41207570,"uuid":"100935205","full_name":"ethanhe42/channel-pruning","owner":"ethanhe42","description":"Channel Pruning for Accelerating Very Deep Neural Networks (ICCV'17)","archived":false,"fork":false,"pushed_at":"2024-05-02T06:37:43.000Z","size":561,"stargazers_count":1082,"open_issues_count":21,"forks_count":310,"subscribers_count":47,"default_branch":"master","last_synced_at":"2025-05-08T08:41:04.662Z","etag":null,"topics":["acceleration","channel-pruning","deep-neural-networks","image-classification","image-recognition","model-compression","object-detection"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/1707.06168","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethanhe42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"yihuihe","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2017-08-21T09:19:53.000Z","updated_at":"2025-04-19T13:34:45.000Z","dependencies_parsed_at":"2024-11-16T17:04:08.137Z","dependency_job_id":"01c1e376-6776-4a1f-9750-4366a341682b","html_url":"https://github.com/ethanhe42/channel-pruning","commit_stats":{"total_commits":54,"total_committers":4,"mean_commits":13.5,"dds":"0.42592592592592593","last_synced_commit":"1d66cfff960747ba514bf6580dcd2e17e321e788"},"previous_names":["ethanhe42/channel-pruning","yihui-he/channel-pruning"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanhe42%2Fchannel-pruning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanhe42%2Fchannel-pruning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanhe42%2Fchannel-pruning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethanhe42%2Fchannel-pruning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethanhe42","download_url":"https://codeload.github.com/ethanhe42/channel-pruning/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254459088,"owners_count":22074605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acceleration","channel-pruning","deep-neural-networks","image-classification","image-recognition","model-compression","object-detection"],"created_at":"2024-08-03T21:00:52.521Z","updated_at":"2025-05-16T03:05:51.799Z","avatar_url":"https://github.com/ethanhe42.png","language":"Python","funding_links":["https://ko-fi.com/yihuihe"],"categories":["3.) Model Compression \u0026 Acceleration","神经网络结构搜索_Neural_Architecture_Search"],"sub_categories":["**[Papers]**"],"readme":"# Channel Pruning for Accelerating Very Deep Neural Networks\n\n![image](https://github.com/ethanhe42/channel-pruning/assets/10027339/8a7793a8-927f-49bc-84cf-0d33f76d3ae4)\n\n\n[GitHub - yihui-he/channel-pruning: Channel Pruning for Accelerating Very Deep Neural Networks (ICCV'17)](https://github.com/yihui-he/channel-pruning)\n\n[Channel Pruning for Accelerating Very Deep Neural Networks](https://arxiv.org/abs/1707.06168)\n\n**ICCV 2017**, by [Yihui He](http://yihui-he.github.io/), [Xiangyu Zhang](https://scholar.google.com/citations?user=yuB-cfoAAAAJ\u0026hl=en\u0026oi=ao) and [Jian Sun](http://jiansun.org/)\n\nPlease have a look our new works on compressing deep models: \n\n- [AMC: AutoML for Model Compression and Acceleration on Mobile Devices](http://openaccess.thecvf.com/content_ECCV_2018/html/Yihui_He_AMC_Automated_Model_ECCV_2018_paper.html) **ECCV’18**, which combines channel pruning and reinforcement learning to further accelerate CNN. [code](https://github.com/mit-han-lab/amc-release) and [models](https://github.com/mit-han-lab/amc-compressed-models) are available!\n- [AddressNet: Shift-Based Primitives for Efficient Convolutional Neural Networks](https://arxiv.org/abs/1809.08458) **WACV’19**. We propose a family of efficient networks based on Shift operation.\n- [MoBiNet: A Mobile Binary Network for Image Classification](https://arxiv.org/abs/1907.12629) **WACV’20** Binarized MobileNets.\n\nIn this repository, we released code for the following models:\n\n| model | Speed-up | Accuracy |\n| --- | --- | --- |\n| https://github.com/yihui-he/channel-pruning/releases/tag/channel_pruning_5x | 5x | 88.1 (Top-5), 67.8 (Top-1) |\n| https://github.com/yihui-he/channel-pruning/releases/tag/VGG-16_3C4x | 4x | 89.9 (Top-5), 70.6 (Top-1) |\n| https://github.com/yihui-he/channel-pruning/releases/tag/ResNet-50-2X | 2x | 90.8 (Top-5), 72.3 (Top-1) |\n| https://github.com/yihui-he/channel-pruning/releases/tag/faster-RCNN-2X4X | 2x | 36.7 (AP@.50:.05:.95) |\n| https://github.com/yihui-he/channel-pruning/releases/tag/faster-RCNN-2X4X | 4x | 35.1 (AP@.50:.05:.95) |\n\n3C method combined spatial decomposition ([Speeding up Convolutional Neural Networks with Low Rank Expansions](https://arxiv.org/abs/1405.3866)) and channel decomposition ([Accelerating Very Deep Convolutional Networks for Classification and Detection](https://arxiv.org/abs/1505.06798)) (mentioned in 4.1.2)\n\n### Citation\n\nIf you find the code useful in your research, please consider citing:\n\n```\n@InProceedings{He_2017_ICCV,\nauthor = {He, Yihui and Zhang, Xiangyu and Sun, Jian},\ntitle = {Channel Pruning for Accelerating Very Deep Neural Networks},\nbooktitle = {The IEEE International Conference on Computer Vision (ICCV)},\nmonth = {Oct},\nyear = {2017}\n}\n```\n\n### requirements\n\n1. Python3 packages you might not have: `scipy`, `sklearn`, `easydict`, use `sudo pip3 install` to install.\n2. For finetuning with 128 batch size, 4 GPUs (~11G of memory)\n\n### Installation (sufficient for the demo)\n\n1. Clone the repository\n    \n    ```bash\n    # Make sure to clone with --recursive\n     git clone --recursive https://github.com/yihui-he/channel-pruning.git\n    ```\n    \n2. Build [my Caffe](https://github.com/yihui-he/caffe-pro) fork (which support bicubic interpolation and resizing image shorter side to 256 then crop to 224x224) \n    \n    ```bash\n    cd caffe\n    \n     # If you're experienced with Caffe and have all of the requirements installed, then simply do:\n     make all -j8 \u0026\u0026 make pycaffe\n     # Or follow the Caffe installation instructions here:\n     # http://caffe.berkeleyvision.org/installation.html\n    \n     # you might need to add pycaffe to PYTHONPATH, if you've already had a caffe before\n    ```\n    \n3. Download ImageNet classification dataset http://www.image-net.org/download-images\n4. Specify imagenet `source` path in `temp/vgg.prototxt` (line 12 and 36)\n\n### Channel Pruning\n\n*For fast testing, you can directly download pruned model. See [next section](about:blank#pruned-models-for-download)* 1. Download the original VGG-16 model http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel\nmove it to `temp/vgg.caffemodel` (or create a softlink instead)\n\n1. Start Channel Pruning \n    \n    ```bash\n    python3 train.py -action c3 -caffe [GPU0]\n     # or log it with ./run.sh python3 train.py -action c3 -caffe [GPU0]\n     # replace [GPU0] with actual GPU device like 0,1 or 2\n    ```\n    \n2. Combine some factorized layers for further compression, and calculate the acceleration ratio. Replace the ImageData layer of `temp/cb_3c_3C4x_mem_bn_vgg.prototxt` with `[temp/vgg.prototxt`’s](https://github.com/yihui-he/channel-pruning/blob/master/temp/vgg.prototxt#L1-L49) `Shell ./combine.sh | xargs ./calflop.sh`\n3. Finetuning \n    \n    ```bash\n    caffe train -solver temp/solver.prototxt -weights temp/cb_3c_vgg.caffemodel -gpu [GPU0,GPU1,GPU2,GPU3]\n     # replace [GPU0,GPU1,GPU2,GPU3] with actual GPU device like 0,1,2,3\n    ```\n    \n4. Testing\n    \n    Though testing is done while finetuning, you can test anytime with: \n    \n    ```bash\n    caffe test -model path/to/prototxt -weights path/to/caffemodel -iterations 5000 -gpu [GPU0]\n     # replace [GPU0] with actual GPU device like 0,1 or 2\n    ```\n    \n    Pruned models (for download) \n    \n    For fast testing, you can directly download pruned model from [release](https://github.com/yihui-he/channel-pruning/releases): [VGG-16 3C 4X](https://github.com/yihui-he/channel-pruning/releases/tag/VGG-16_3C4x), [VGG-16 5X](https://github.com/yihui-he/channel-pruning/releases/tag/channel_pruning_5x), [ResNet-50 2X](https://github.com/yihui-he/channel-pruning/releases/tag/ResNet-50-2X). Or follow Baidu Yun [Download link](https://pan.baidu.com/s/1c2evwTa)\n    \n\nTest with:\n\n```\ncaffe test -model channel_pruning_VGG-16_3C4x.prototxt -weights channel_pruning_VGG-16_3C4x.caffemodel -iterations 5000 -gpu [GPU0]\n# replace [GPU0] with actual GPU device like 0,1 or 2\n```\n\n### Pruning faster RCNN\n\nFor fast testing, you can directly download pruned model from [release](https://github.com/yihui-he/channel-pruning/releases/tag/faster-RCNN-2X4X)\nOr you can: 1. clone my py-faster-rcnn repo: https://github.com/yihui-he/py-faster-rcnn 2. use the [pruned models](https://github.com/yihui-he/channel-pruning/releases/tag/faster-RCNN-2X4X) from this repo to train faster RCNN 2X, 4X, solver prototxts are in https://github.com/yihui-he/py-faster-rcnn/tree/master/models/pascal_voc\n\n### FAQ\n\nYou can find answers of some commonly asked questions in our [Github wiki](https://github.com/yihui-he/channel-pruning/wiki), or just create a [new issue](https://github.com/yihui-he/channel-pruning/issues/new)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanhe42%2Fchannel-pruning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethanhe42%2Fchannel-pruning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethanhe42%2Fchannel-pruning/lists"}