{"id":20207217,"url":"https://github.com/pathak22/ccnn","last_synced_at":"2025-06-17T21:33:11.599Z","repository":{"id":85023064,"uuid":"47687300","full_name":"pathak22/ccnn","owner":"pathak22","description":"[ICCV 2015] Framework for optimizing CNNs with linear constraints for Semantic Segmentation","archived":false,"fork":false,"pushed_at":"2016-05-03T15:59:17.000Z","size":289,"stargazers_count":64,"open_issues_count":2,"forks_count":27,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T12:55:26.438Z","etag":null,"topics":["computer-vision","constraints","deep-learning","fcn","fully-convolutional-networks","linear-constraints","machine-learning","segmentation"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pathak22.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2015-12-09T11:29:48.000Z","updated_at":"2024-02-23T19:57:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b876f8d-22c1-45e0-8f67-a42df579a020","html_url":"https://github.com/pathak22/ccnn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pathak22/ccnn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathak22%2Fccnn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathak22%2Fccnn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathak22%2Fccnn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathak22%2Fccnn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pathak22","download_url":"https://codeload.github.com/pathak22/ccnn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathak22%2Fccnn/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260442534,"owners_count":23009856,"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":["computer-vision","constraints","deep-learning","fcn","fully-convolutional-networks","linear-constraints","machine-learning","segmentation"],"created_at":"2024-11-14T05:28:02.256Z","updated_at":"2025-06-17T21:33:06.561Z","avatar_url":"https://github.com/pathak22.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"## CCNN: Constrained Convolutional Neural Networks for Weakly Supervised Segmentation\n\n[Deepak Pathak](http://cs.berkeley.edu/~pathak), [Philipp Kr\u0026auml;henb\u0026uuml;hl](http://www.philkr.net/), [Trevor Darrell](http://cs.berkeley.edu/~trevor)\n\n**CCNN** is a framework for optimizing convolutional neural networks with linear constraints.\n - It has been shown to achieve state-of-the-art results on the task of weakly-supervised semantic segmentation.\n - It is written in Python and C++, and based on [Caffe](http://caffe.berkeleyvision.org/).\n - It has been published at **ICCV 2015**. It was initially described in the [arXiv report](http://arxiv.org/abs/1506.03648).\n\nIf you find CCNN useful in your research, please cite:\n\n    @inproceedings{pathakICCV15ccnn,\n        Author = {Pathak, Deepak and Kr\\\"ahenb\\\"uhl, Philipp and Darrell, Trevor},\n        Title = {Constrained Convolutional Neural Networks for Weakly Supervised Segmentation},\n        Booktitle = {International Conference on Computer Vision ({ICCV})},\n        Year = {2015}\n    }\n\n### License\n\nCCNN is released under academic, non-commercial UC Berkeley license (see [LICENSE](https://github.com/pathak22/ccnn/blob/master/LICENSE) file for details). \n\n### Contents\n1. [Requirements](#1-requirements)\n2. [Installation](#2-installation)\n3. [Usage](#3-usage)\n4. [Scripts Information](#4-scripts-information)\n5. [Extra Downloads](#5-extra-downloads)\n\n### 1) Requirements\n\n1. Requirements for `Caffe` and `pycaffe` (see: [Caffe installation instructions](http://caffe.berkeleyvision.org/installation.html))\n2. GCC version more than 4.7\n3. Boost version more than 1.53 (recommended). If system dependencies give issues, install anaconda dependencies:\n\n  ```\n  $ conda install boost\n  $ conda install protobuf\n  ```\n  \n4. A good GPU (e.g., Titan, K20, K40, ...) with at least 3G of memory is sufficient.\n\n### 2) Installation\n\n1. Clone the CCNN repository\n  ```Shell\n  # Make sure to clone with --recursive\n  git clone --recursive https://github.com/pathak22/ccnn.git\n  ```\n  \n2. Build Caffe and pycaffe\n\n  - Now follow the Caffe installation instructions [here](http://caffe.berkeleyvision.org/installation.html)\n  - Caffe *must* be built with support for Python layers!\n  - In your Makefile.config, make sure to have this line uncommented\n    `WITH_PYTHON_LAYER := 1`\n  - You can download my [Makefile.config](http://www.cs.berkeley.edu/~pathak/ccnn/Makefile.config) for reference.\n  \n  ```Shell\n  cd ccnn/caffe-ccnn\n  # If you have all caffe requirements installed\n  # and your Makefile.config in place, then simply do:\n  make -j8 \u0026\u0026 make pycaffe\n  ```\n    \n3. Now build CCNN\n\n    ```Shell\n    cd ccnn\n    mkdir build\n    cd build\n    cmake ..\n    make -j8\n    ```\n    \n  - **Note:** If anaconda is installed, then python paths may have been messed b/w anaconda and system python. \n  - I usually run this command : \n\n  ```Shell\n  cmake .. -DBOOST_ROOT=/home/pathak/anaconda -DPYTHON_LIBRARY=/home/pathak/anaconda/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/home/pathak/anaconda/include/python2.7/ -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8\n  ```\n  \n  - To verify this do : `ccmake ./` inside the build folder and manually check the following things : \n  `MAKE_CXX_COMPILER, CMAKE_C_COMPILER , PYTHON_EXECUTABLE , PYTHON_INCLUDE_DIR , PYTHON_LIBRARY`\n  - Make sure that cmake doesn't mess the anaconda boost to system boost.\n\n4. Configure path (if needed) in `src/user_config.py`.\n\n5. (Optional -- I don't do it) If everything runs fine, set `CMAKE_BUILD_TYPE` using `ccmake .` to `Release`. This prevents eigen from checking all assertions etc. and works faster.\n\n### 3) Usage\n\n**Demo** CCNN.\n\n```Shell\ncd ccnn\nbash ./models/scripts/download_ccnn_models.sh\n# This will populate the `ccnn/models/` folder with trained models.\npython ./src/demo.py\n```\n\n**Train** CCNN.\n\n```Shell\ncd ccnn\nbash ./models/scripts/download_pretrained_models.sh\n# This will populate the `ccnn/models/` folder with imagenet pre-trained models.\npython ./src/train.py 2\u003e log.txt\n```\n\n**Test** CCNN.\n\n```Shell\ncd ccnn\npython ./src/test.py  # To test IOU with CRF post-processing\npython ./src/test_argmax.py  # To test IOU without CRF\n```\n\n### 4) Scripts Information\n\nModel Prototxts:\n- `models/fcn_8s/` : Atrous algorithm based 8-strided VGG, described [here](http://arxiv.org/abs/1412.7062).\n- `models/fcn_32s/` : 32-strided VGG\n\nConfigure:\n- `src/config.py` : Set glog-minlevel accordingly to get desired caffe output to terminal\n\nHelper Scripts:\n- `src/extras/` : These scripts are not needed to run the code. They are simple helper scripts to create data, to prepare pascal test server file, to add pascal cmap to segmentation outputs etc.\n\n### 5) Extra Downloads\n\n- Pascal VOC Image List: [train](http://www.cs.berkeley.edu/~pathak/ccnn/train.txt), [val](http://www.cs.berkeley.edu/~pathak/ccnn/val.txt), [trainval](http://www.cs.berkeley.edu/~pathak/ccnn/trainval.txt), [test](http://www.cs.berkeley.edu/~pathak/ccnn/test.txt)\n- [Training image-level label indicator files](http://www.cs.berkeley.edu/~pathak/ccnn/trainIndicatorFiles.tar.gz)\n- [Pascal VOC 2012 validation result images](http://www.cs.berkeley.edu/~pathak/ccnn/voc_2012_val_results.tar.gz)\n- [Pascal VOC 2012 test result images](http://www.cs.berkeley.edu/~pathak/ccnn/voc_2012_test_results.tar.gz)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathak22%2Fccnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpathak22%2Fccnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathak22%2Fccnn/lists"}