1 Star 0 Fork 0

chenruilin2024 / csgm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Compressed Sensing using Generative Models

This repository provides code to reproduce results from the paper: Compressed Sensing using Generative Models.

Here are a few example results:

Reconstruction Super-resolution Inpainting
celebA_reconstr celebA_superres celebA_inpaint
mnist_reconstr mnist_superres mnist_inpaint

Here we show the evolution of the reconstructed image for different number of iterations:

Steps to reproduce the results

NOTE: Please run all commands from the root directory of the repository, i.e from csgm/

Requirements:


  1. Python 2.7
  2. Tensorflow 1.0.1
  3. Scipy
  4. PyPNG
  5. (Optional : for lasso-wavelet) PyWavelets
  6. (Optional) CVXOPT

Pip installation can be done by $ pip install -r requirements.txt

Preliminaries


  1. Clone the repository and dependencies

    $ git clone https://github.com/AshishBora/csgm.git
    $ cd csgm
    $ git submodule update --init --recursive
  2. Download/extract the datasets:

    $ ./setup/download_data.sh
  3. Download/extract pretrained models or train your own!

  4. To use wavelet based estimators, you need to create the basis matrix:

    $ python ./src/wavelet_basis.py

Demos


The following are the supported experiments and example commands to run the demos:

[Note: For celebA experiments, we run very few iterations per experiment (30) to give a quick demo. To get results with better quality, increase the number of iterations to at least 500 and use at least 2 random restarts.]

  1. Reconstruction from Gaussian measurements
    • $ ./quick_scripts/mnist_reconstr.sh
    • $ ./quick_scripts/celebA_reconstr.sh "./images/182659.jpg"
  2. Super-resolution
    • $ ./quick_scripts/mnist_superres.sh
    • $ ./quick_scripts/celebA_superres.sh "./images/182659.jpg"
  3. Reconstruction for images in the span of the generator
    • $ ./quick_scripts/mnist_genspan.sh
    • $ ./quick_scripts/celebA_genspan.sh
  4. Quantifying representation error
    • $ ./quick_scripts/mnist_projection.sh
    • $ ./quick_scripts/celebA_projection.sh "./images/182659.jpg"
  5. Inpainting
    • $ ./quick_scripts/mnist_inpaint.sh
    • $ ./quick_scripts/celebA_inpaint.sh "./images/182659.jpg"

Reproducing quantitative results


  1. Create a scripts directory $ mkdir scripts

  2. Identfy a dataset you would like to get the quantitative results on. Locate the file ./quant_scripts/{dataset}_reconstr.sh.

  3. Change BASE_SCRIPT in src/create_scripts.py to be the same as given at the top of ./quant_scripts/{dataset}_reconstr.sh.

  4. Optionally, comment out the parts of ./quant_scripts/{dataset}_reconstr.sh that you don't want to run.

  5. Run ./quant_scripts/{dataset}_reconstr.sh. This will create a bunch of .sh files in the ./scripts/ directory, each one of them for a different parameter setting.

  6. Start running these scripts.

    • You can run $ ./utils/run_sequentially.sh to run them one by one.
    • Alternatively use $ ./utils/run_all_by_number.sh to create screens and start proccessing them in parallel. [REQUIRES: gnu screen][WARNING: This may overwhelm the computer]. You can use $ ./utils/stop_all_by_number.sh to stop the running processes, and clear up the screens started this way.
  7. Create a results directory : $ mkdir results. To get the plots, see src/metrics.ipynb. To get matrix of images (as in the paper), run $ python src/view_estimated_{dataset}.py.

  8. You can also manually access the results saved by the scripts. These can be found in appropriately named directories in estimated/. Directory name conventions are defined in get_checkpoint_dir() in src/utils.py

Miscellaneous


For a complete list of images not used while training on celebA, see here.

MIT License Copyright (c) 2017 Ashish Bora Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/chenruilin2024/csgm.git
git@gitee.com:chenruilin2024/csgm.git
chenruilin2024
csgm
csgm
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891