|
Download README.md from CaiYuanhao/BiSCI: direct link, hf CLI and curl.
- Browser
- Download file 7.39 kB
-
https://huggingface.co/CaiYuanhao/BiSCI/resolve/main/README.md
- Command line
-
hf download hf://CaiYuanhao/BiSCI/README.md
-
curl -L -o README.md https://huggingface.co/CaiYuanhao/BiSCI/resolve/main/README.md
7.39 kB
| license: apache-2.0 | |
| language: | |
| - en | |
| library_name: pytorch | |
| tags: | |
| - hyperspectral-image-reconstruction | |
| - spectral-compressive-imaging | |
| - snapshot-compressive-imaging | |
| - spectral-reconstruction | |
| - binary-neural-network | |
| - model-zoo | |
| - arxiv:2305.10299 | |
| # BiSCI: A Toolbox for Binarized Spectral Compressive Imaging | |
| <p> | |
| <a href="https://github.com/caiyuanhao1998/BiSCI"><img src="https://img.shields.io/badge/GitHub-Code-181717?logo=github" height="20" style="vertical-align:middle;" alt="GitHub code"></a> | |
| <a href="https://arxiv.org/abs/2305.10299"><img src="https://img.shields.io/badge/arXiv-BiSCI-B31B1B" height="20" style="vertical-align:middle;" alt="arXiv paper"></a> | |
| <a href="https://arxiv.org/abs/2305.10299"><img src="https://img.shields.io/badge/NeurIPS-2023-FF5797" height="20" style="vertical-align:middle;" alt="NeurIPS 2023"></a> | |
| <a href="https://zhuanlan.zhihu.com/p/668862020"><img src="https://img.shields.io/badge/η₯δΉθ§£θ―»-BiSCI-0084FF" height="20" style="vertical-align:middle;" alt="η₯δΉθ§£θ―»"></a> | |
| </p> | |
| [Code and project documentation](https://github.com/caiyuanhao1998/BiSCI) | |
| ## Overview | |
| This repository provides pretrained PyTorch checkpoints for **binarized spectral compressive imaging reconstruction**, including **BiSRNet** and seven binary neural network baselines supported by the BiSCI toolbox. | |
| The models reconstruct hyperspectral image cubes with **28 spectral bands** from coded snapshot measurements. Simulation testing generates the measurements from the provided hyperspectral ground truth and sensing mask; real testing reconstructs the captured measurements directly. | |
| **[Binarized Spectral Compressive Imaging](https://arxiv.org/abs/2305.10299) β NeurIPS 2023** introduces the Binarized Spectral-Redistribution Network (BiSRNet). Its BiSR-Conv units redistribute spectral representations before binarization and use a scalable hyperbolic tangent approximation during backpropagation. | |
| **Authors:** Yuanhao Cai, Yuxin Zheng, Jing Lin, Xin Yuan, Yulun Zhang, and Haoqian Wang. | |
| <p align="center"> | |
| <img src="https://raw.githubusercontent.com/caiyuanhao1998/BiSCI/master/fig/pipeline.png" width="900" alt="BiSRNet architecture"> | |
| </p> | |
| ## Reconstruction examples | |
| Simulation and real reconstruction comparisons from the project: | |
| <p align="center"> | |
| <img src="https://raw.githubusercontent.com/caiyuanhao1998/BiSCI/master/fig/simu_qualitative_compare.png" width="900" alt="Simulation reconstruction comparison"> | |
| <img src="https://raw.githubusercontent.com/caiyuanhao1998/BiSCI/master/fig/real_compare.png" width="900" alt="Real reconstruction comparison"> | |
| </p> | |
| ## Available checkpoints | |
| There are **12 checkpoints: 8 for simulation and 4 for real experiments**. Each checkpoint requires the matching architecture and method setting in the corresponding part of the toolbox. | |
| | Method | `--method` | Simulation checkpoint | Real checkpoint | | |
| | --- | --- | --- | --- | | |
| | BiConnect | `biconnect` | `Simu_models/biconnect.pth` | `Real_models/biconnect.pth` | | |
| | BNN | `bnn` | `Simu_models/bnn.pth` | `Real_models/bnn.pth` | | |
| | Bi-Real Net | `bireal` | `Simu_models/bireal.pth` | β | | |
| | IR-Net | `irnet` | `Simu_models/irnet.pth` | β | | |
| | ReActNet | `reactnet` | `Simu_models/reactnet.pth` | `Real_models/reactnet.pth` | | |
| | BBCU | `bbcu` | `Simu_models/bbcu.pth` | β | | |
| | BTM | `btm` | `Simu_models/btm.pth` | β | | |
| | BiSRNet | `bisrnet` | `Simu_models/bisrnet.pth` | `Real_models/bisrnet.pth` | | |
| The real training code supports all eight architectures. For the four methods without a released real checkpoint here, train a model using the real training code before testing. | |
| ## Getting started | |
| ### 1. Install the toolbox | |
| Use Python 3.10 and an NVIDIA GPU. The following configuration was tested with PyTorch 2.5.1 and CUDA 12.1 wheels: | |
| ```bash | |
| git clone https://github.com/caiyuanhao1998/BiSCI.git | |
| cd BiSCI | |
| conda create -n bisci python=3.10 -y | |
| conda activate bisci | |
| python -m pip install torch==2.5.1 torchvision==0.20.1 --index-url https://download.pytorch.org/whl/cu121 | |
| python -m pip install -r requirements.txt | |
| python -m pip check | |
| ``` | |
| ### 2. Download the model weights | |
| The root `config.json` lists this repository's checkpoints, supporting files, and implementation. Include it when downloading selected weights so those downloads can be counted by the [Hugging Face Hub](https://huggingface.co/docs/hub/models-download-stats). Use the linked implementation and its matching runtime configuration to load the checkpoints. | |
| From the BiSCI repository root, download the weights while preserving the checkpoint subdirectories: | |
| ```bash | |
| # All eight simulation checkpoints | |
| hf download CaiYuanhao/BiSCI --include "config.json" "Simu_models/*.pth" --local-dir simulation/test_code/model_zoo | |
| # All four real checkpoints | |
| hf download CaiYuanhao/BiSCI --include "config.json" "Real_models/*.pth" --local-dir real/test_code/model_zoo | |
| ``` | |
| To download only the simulation BiSRNet checkpoint: | |
| ```bash | |
| hf download CaiYuanhao/BiSCI config.json Simu_models/bisrnet.pth --local-dir simulation/test_code/model_zoo | |
| ``` | |
| For example, this saves `simulation/test_code/model_zoo/Simu_models/bisrnet.pth`. | |
| ### 3. Prepare the test data | |
| Follow the [dataset preparation instructions](https://github.com/caiyuanhao1998/BiSCI#2-prepare-dataset) to download the test scenes and sensing mask separately. This model repository contains the pretrained weights. | |
| ```text | |
| BiSCI/ | |
| βββ datasets/ | |
| βββ TSA_simu_data/ | |
| β βββ mask.mat | |
| β βββ Truth/ | |
| β βββ scene01.mat | |
| β βββ ... | |
| β βββ scene10.mat | |
| βββ TSA_real_data/ | |
| βββ mask.mat | |
| βββ Measurements/ | |
| βββ scene1.mat | |
| βββ ... | |
| βββ scene5.mat | |
| ``` | |
| Simulation test scenes contain `img` arrays of shape `256 Γ 256 Γ 28`, and the simulation `mask.mat` contains a `256 Γ 256` mask. Real measurement files contain `meas_real` arrays of shape `660 Γ 714`. | |
| ### 4. Run simulation testing | |
| From the BiSCI repository root: | |
| ```bash | |
| cd simulation/test_code | |
| python test.py --method bisrnet --pretrained_model_path ./model_zoo/Simu_models/bisrnet.pth --outf ./exp/bisrnet/ | |
| ``` | |
| The reconstructed cubes are saved in `simulation/test_code/exp/bisrnet/Test_result.mat`. The file contains `pred` and `truth`, both shaped `10 Γ 256 Γ 256 Γ 28`. | |
| ### 5. Run real testing | |
| From the BiSCI repository root: | |
| ```bash | |
| cd real/test_code | |
| python test.py --method bisrnet --pretrained_model_path ./model_zoo/Real_models/bisrnet.pth | |
| ``` | |
| The five reconstructions are saved as `real/test_code/results/bisrnet/1.mat` through `5.mat`. Each contains a `res` array shaped `660 Γ 660 Γ 28`. | |
| The scripts use GPU 0 by default. Add `--gpu_id N` to select another GPU. See the [GitHub README](https://github.com/caiyuanhao1998/BiSCI) for other methods, training, metrics, and visualization instructions. | |
| ## Citation | |
| ```bibtex | |
| @inproceedings{bisci, | |
| title={Binarized Spectral Compressive Imaging}, | |
| author={Yuanhao Cai and Yuxin Zheng and Jing Lin and Xin Yuan and Yulun Zhang and Haoqian Wang}, | |
| booktitle={NeurIPS}, | |
| year={2023} | |
| } | |
| ``` | |
| ## License | |
| The model repository retains its Apache 2.0 license metadata. The toolbox source code is distributed under the [MIT license](https://github.com/caiyuanhao1998/BiSCI/blob/master/LICENSE.txt). | |