tenet-official 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Guocheng Qian @ SenseTime
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: tenet_official
3
+ Version: 0.1.0
4
+ Summary: TENet (ICCP'22) release metadata and resource helpers for pip users: paper, PixelShift200 dataset, model list, and pretrained-weight loading info.
5
+ Author: Guocheng Qian
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/guochengqian/TENet
8
+ Project-URL: Repository, https://github.com/guochengqian/TENet
9
+ Project-URL: Paper, https://arxiv.org/abs/1905.02538
10
+ Project-URL: Dataset, http://guochengqian.github.io/project/pixelshift200
11
+ Keywords: demosaicing,denoising,super-resolution,ISP,raw,pytorch,TENet,PixelShift200
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Provides-Extra: dev
27
+ Requires-Dist: build>=1; extra == "dev"
28
+ Requires-Dist: twine>=4; extra == "dev"
29
+ Requires-Dist: pytest>=7; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # TENet <a href="https://arxiv.org/abs/1905.02538" target="_blank">[ArXiv]</a> <a href="http://guochengqian.github.io/project/pixelshift200">[pixelshift200]</a>
33
+
34
+ ### Rethinking Learning-based Demosaicing, Denoising, and Super-Resolution Pipeline
35
+ By [Guocheng Qian*](https://guochengqian.github.io/), [Yuanhao Wang*](https://github.com/yuanhaowang1213), [Jinjin Gu](http://www.jasongt.com/), Chao Dong, Wolfgang Heidrich, Bernard Ghanem, [Jimmy S. Ren](http://www.jimmyren.com/)
36
+
37
+ The original name of this project is: "Trinity of Pixel Enhancement: a Joint Solution for Demosaicking, Denoising and Super-Resolution"
38
+
39
+
40
+
41
+ ## TENet
42
+
43
+ We insert the proposed pipeline DN -> SR -> DM into an end-to-end network constructed by RRDB for the joint DN, DM and SR. We leverage the detachable branch to provide the middle stage supervision.
44
+
45
+
46
+ <p align="center">
47
+ <img height="300" src="misc/Network.png">
48
+ </p>
49
+
50
+
51
+
52
+
53
+ ## PixelShift200 dataset
54
+
55
+ We employ advanced pixel shift technology to perform a full color sampling of the image.
56
+ Pixel shift technology takes four samples of the same image, and physically controls the camera sensor to move one pixel horizontally or vertically at each sampling to capture all color information at each pixel.
57
+ The pixel shift technology ensures that the sampled images follow the distribution of natural images sampled by the camera, and the full information of the color is completely obtained.
58
+ In this way, the collected images are artifacts-free, which leads to better training results for demosaicing related tasks.
59
+
60
+ <p align="center">
61
+ <img height="200" src="misc/PixelShift.png">
62
+ </p>
63
+
64
+
65
+ Download PixelShift200 and the original RAW files from [pxielshift200 website](http://guochengqian.github.io/project/pixelshift200) for using this [Google Drive Link](https://drive.google.com/drive/folders/1S1mt9D8IlpSAVm7RTjLheh1hTaltsV_f?usp=share_link)
66
+
67
+
68
+ ### Environment installation
69
+
70
+ Clone this github repo and install the environment by:
71
+
72
+ ```bash
73
+ git clone https://github.com/guochengqian/TENet
74
+ cd TENet
75
+ source install.sh
76
+ conda activate tenet
77
+ ```
78
+
79
+
80
+
81
+ ### Data preparation
82
+
83
+ 1. synthetic data preparation [Optional]
84
+ Processing synthetic dataset if you are interested in synthetic benchmark.
85
+ 1. Download ([DIV2K](https://drive.google.com/file/d/1vXPPr2hVaMewz2JA1lFfI5uHB4ENwRXQ/view?usp=sharing)) dataset
86
+
87
+ 2. `mkdir data && cd data`
88
+
89
+ 3. Link DIV2K data into ./data/DIV2K, e.g. `ln -s /data/lowlevel/DIV2K ./`
90
+
91
+ 4. Crop DIV2K
92
+
93
+ ```bash
94
+ cd ../datasets
95
+ python crop_imgs.py # crop train images
96
+ python crop_imgs.py --src_dir ../data/DIV2K/DIV2K_val5_HR --save_dir ../data/DIV2K/DIV2K_val5_HR_sub # crop val5 images
97
+ ```
98
+
99
+ 2. PixelShift200 data preparation
100
+ Processing PixelShift200 dataset if you are interested in PixelShift200 benchmark.
101
+ 1. Download [Pixelshift200](http://guochengqian.com/pixelshift200). They are .mat format, having 4 channels (R, Gr, Gb, B). Unzip the .zip file and put all folders inside into one folder called pixelshift200. For example, put here `/data/lowlevel/pixelshift200`.
102
+
103
+ 2. `cd TENet && mkdir data && cd data`
104
+
105
+ 3. Link PixelShift200 data into ./data/pixelshift200, e.g. `ln -s /data/lowlevel/pixelshift200 pixelshift200`
106
+
107
+ 4. Crop images into 512*512, and generate the text file that contains the location of each image:
108
+
109
+ ```bash
110
+ cd ../datasets
111
+ python crop_pixelshift200.py
112
+ python generate_datalist_pixelshift.py
113
+ ```
114
+
115
+
116
+ ## Training
117
+ #### Train joint models
118
+
119
+ * DN+SR->DM (our **TENet**)
120
+
121
+ ```bash
122
+ python train.py --in_type noisy_lr_raw --mid_type raw --out_type linrgb --model tenet --n_gpus 4 --block rrdb --n_blocks 12
123
+ ```
124
+
125
+ * DN+DM+SR [Optional] (baseline: end to end without pipeline)
126
+
127
+ ```bash
128
+ python train.py --in_type noisy_lr_raw --mid_type None --out_type linrgb --model tenet --n_gpus 4 --block rrdb --n_blocks 12
129
+ ```
130
+
131
+ Note:
132
+
133
+ 1. `--mid_type raw` is to activate the auxiliary mid stage supervision. Here we add `raw` as the supervision, therefore, the pipeline will be DN+SR->DM
134
+
135
+ 2. for training on a different dataset, like DIV2K, change `--dataset div2k`
136
+
137
+ 3. for training with Gaussian noise model, add `--noise_model g`
138
+
139
+ 4. for using a different building block, such as NLSA `--block nlsa`, or EAM `--block eam` , or RRG `--block rrg`, or DRLM `--block drlm` or RRDB `--block rrdb`
140
+
141
+ 5. [`wandb`](https://wandb.ai/) is used by default. Set `--no_wandb` to not using wandb
142
+
143
+
144
+
145
+ #### Train sequential models [Optional] (ablation study)
146
+
147
+ ```bash
148
+ # RawDN
149
+ python train.py --in_type noisy_raw --out_type raw --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
150
+
151
+ # RawSR
152
+ python train.py --in_type lr_raw --out_type raw --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
153
+
154
+ # DM
155
+ python train.py --in_type raw --out_type linrgb --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
156
+
157
+ # RGBDN
158
+ python train.py --in_type noisy_linrgb --out_type linrgb --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
159
+
160
+ # RGBSR
161
+ python train.py --in_type lr_linrgb --out_type linrgb --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
162
+ ```
163
+
164
+
165
+ ### Train SOTA models [Optional]
166
+ We also support training previous work.
167
+
168
+ * JDSR
169
+ ```bash
170
+ python train.py --in_type noisy_lr_raw --mid_type None --out_type linrgb --model jdsr --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block res --n_blocks 12 --channels 256
171
+ ```
172
+
173
+ * JDnDmSR
174
+
175
+ ```bash
176
+ python train.py --in_type noisy_lr_raw --mid_type lr_raw --out_type linrgb --model jdndmsr --scale 2 --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --n_blocks 2 --block rcab
177
+ ```
178
+
179
+
180
+ ## Testing
181
+
182
+ ```bash
183
+ bash script_all_pipelines.sh
184
+ ```
185
+ This script supports evaluation on all benchmarking datasets as well as the real-shot images for all possible pipelines. Check this script for details
186
+
187
+
188
+ Note: for the real shot images testing, you have to:
189
+
190
+ 1. save the real-shot image as a readable raw image (like in .RAW, .ARW, .DNG format). For example, we use Lightroom mobile version to shot images on iPhone and save the photo in .DNG format.
191
+ 2. Read the general metadata using RawPy and read the noise profiling metadata using [Jeffrey's Image Metadata Viewer](http://exif.regex.info/exif.cgi) or [metapicz](http://metapicz.com/).
192
+
193
+
194
+
195
+ ## Result
196
+ <p align="center">
197
+ <img width="800" src="misc/pipeline_result.png">
198
+ </p>
199
+
200
+
201
+ ### Citation
202
+
203
+ Please cite the following paper if you feel TENet and PixelShift200 is useful to your research
204
+
205
+ ```
206
+ @article{qian2019rethink,
207
+ title={Rethink the Pipeline of Demosaicking, Denoising, and Super-resolution},
208
+ author={Qian, Guocheng and Wang, Yuanhao and Gu, Jinjin and Dong, Chao and Heidrich, Wolfgang and Ghanem, Bernard and Ren, Jimmy S},
209
+ journal={arXiv preprint arXiv:1905.02538},
210
+ year={2019}
211
+ }
212
+ ```
@@ -0,0 +1,181 @@
1
+ # TENet <a href="https://arxiv.org/abs/1905.02538" target="_blank">[ArXiv]</a> <a href="http://guochengqian.github.io/project/pixelshift200">[pixelshift200]</a>
2
+
3
+ ### Rethinking Learning-based Demosaicing, Denoising, and Super-Resolution Pipeline
4
+ By [Guocheng Qian*](https://guochengqian.github.io/), [Yuanhao Wang*](https://github.com/yuanhaowang1213), [Jinjin Gu](http://www.jasongt.com/), Chao Dong, Wolfgang Heidrich, Bernard Ghanem, [Jimmy S. Ren](http://www.jimmyren.com/)
5
+
6
+ The original name of this project is: "Trinity of Pixel Enhancement: a Joint Solution for Demosaicking, Denoising and Super-Resolution"
7
+
8
+
9
+
10
+ ## TENet
11
+
12
+ We insert the proposed pipeline DN -> SR -> DM into an end-to-end network constructed by RRDB for the joint DN, DM and SR. We leverage the detachable branch to provide the middle stage supervision.
13
+
14
+
15
+ <p align="center">
16
+ <img height="300" src="misc/Network.png">
17
+ </p>
18
+
19
+
20
+
21
+
22
+ ## PixelShift200 dataset
23
+
24
+ We employ advanced pixel shift technology to perform a full color sampling of the image.
25
+ Pixel shift technology takes four samples of the same image, and physically controls the camera sensor to move one pixel horizontally or vertically at each sampling to capture all color information at each pixel.
26
+ The pixel shift technology ensures that the sampled images follow the distribution of natural images sampled by the camera, and the full information of the color is completely obtained.
27
+ In this way, the collected images are artifacts-free, which leads to better training results for demosaicing related tasks.
28
+
29
+ <p align="center">
30
+ <img height="200" src="misc/PixelShift.png">
31
+ </p>
32
+
33
+
34
+ Download PixelShift200 and the original RAW files from [pxielshift200 website](http://guochengqian.github.io/project/pixelshift200) for using this [Google Drive Link](https://drive.google.com/drive/folders/1S1mt9D8IlpSAVm7RTjLheh1hTaltsV_f?usp=share_link)
35
+
36
+
37
+ ### Environment installation
38
+
39
+ Clone this github repo and install the environment by:
40
+
41
+ ```bash
42
+ git clone https://github.com/guochengqian/TENet
43
+ cd TENet
44
+ source install.sh
45
+ conda activate tenet
46
+ ```
47
+
48
+
49
+
50
+ ### Data preparation
51
+
52
+ 1. synthetic data preparation [Optional]
53
+ Processing synthetic dataset if you are interested in synthetic benchmark.
54
+ 1. Download ([DIV2K](https://drive.google.com/file/d/1vXPPr2hVaMewz2JA1lFfI5uHB4ENwRXQ/view?usp=sharing)) dataset
55
+
56
+ 2. `mkdir data && cd data`
57
+
58
+ 3. Link DIV2K data into ./data/DIV2K, e.g. `ln -s /data/lowlevel/DIV2K ./`
59
+
60
+ 4. Crop DIV2K
61
+
62
+ ```bash
63
+ cd ../datasets
64
+ python crop_imgs.py # crop train images
65
+ python crop_imgs.py --src_dir ../data/DIV2K/DIV2K_val5_HR --save_dir ../data/DIV2K/DIV2K_val5_HR_sub # crop val5 images
66
+ ```
67
+
68
+ 2. PixelShift200 data preparation
69
+ Processing PixelShift200 dataset if you are interested in PixelShift200 benchmark.
70
+ 1. Download [Pixelshift200](http://guochengqian.com/pixelshift200). They are .mat format, having 4 channels (R, Gr, Gb, B). Unzip the .zip file and put all folders inside into one folder called pixelshift200. For example, put here `/data/lowlevel/pixelshift200`.
71
+
72
+ 2. `cd TENet && mkdir data && cd data`
73
+
74
+ 3. Link PixelShift200 data into ./data/pixelshift200, e.g. `ln -s /data/lowlevel/pixelshift200 pixelshift200`
75
+
76
+ 4. Crop images into 512*512, and generate the text file that contains the location of each image:
77
+
78
+ ```bash
79
+ cd ../datasets
80
+ python crop_pixelshift200.py
81
+ python generate_datalist_pixelshift.py
82
+ ```
83
+
84
+
85
+ ## Training
86
+ #### Train joint models
87
+
88
+ * DN+SR->DM (our **TENet**)
89
+
90
+ ```bash
91
+ python train.py --in_type noisy_lr_raw --mid_type raw --out_type linrgb --model tenet --n_gpus 4 --block rrdb --n_blocks 12
92
+ ```
93
+
94
+ * DN+DM+SR [Optional] (baseline: end to end without pipeline)
95
+
96
+ ```bash
97
+ python train.py --in_type noisy_lr_raw --mid_type None --out_type linrgb --model tenet --n_gpus 4 --block rrdb --n_blocks 12
98
+ ```
99
+
100
+ Note:
101
+
102
+ 1. `--mid_type raw` is to activate the auxiliary mid stage supervision. Here we add `raw` as the supervision, therefore, the pipeline will be DN+SR->DM
103
+
104
+ 2. for training on a different dataset, like DIV2K, change `--dataset div2k`
105
+
106
+ 3. for training with Gaussian noise model, add `--noise_model g`
107
+
108
+ 4. for using a different building block, such as NLSA `--block nlsa`, or EAM `--block eam` , or RRG `--block rrg`, or DRLM `--block drlm` or RRDB `--block rrdb`
109
+
110
+ 5. [`wandb`](https://wandb.ai/) is used by default. Set `--no_wandb` to not using wandb
111
+
112
+
113
+
114
+ #### Train sequential models [Optional] (ablation study)
115
+
116
+ ```bash
117
+ # RawDN
118
+ python train.py --in_type noisy_raw --out_type raw --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
119
+
120
+ # RawSR
121
+ python train.py --in_type lr_raw --out_type raw --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
122
+
123
+ # DM
124
+ python train.py --in_type raw --out_type linrgb --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
125
+
126
+ # RGBDN
127
+ python train.py --in_type noisy_linrgb --out_type linrgb --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
128
+
129
+ # RGBSR
130
+ python train.py --in_type lr_linrgb --out_type linrgb --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
131
+ ```
132
+
133
+
134
+ ### Train SOTA models [Optional]
135
+ We also support training previous work.
136
+
137
+ * JDSR
138
+ ```bash
139
+ python train.py --in_type noisy_lr_raw --mid_type None --out_type linrgb --model jdsr --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block res --n_blocks 12 --channels 256
140
+ ```
141
+
142
+ * JDnDmSR
143
+
144
+ ```bash
145
+ python train.py --in_type noisy_lr_raw --mid_type lr_raw --out_type linrgb --model jdndmsr --scale 2 --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --n_blocks 2 --block rcab
146
+ ```
147
+
148
+
149
+ ## Testing
150
+
151
+ ```bash
152
+ bash script_all_pipelines.sh
153
+ ```
154
+ This script supports evaluation on all benchmarking datasets as well as the real-shot images for all possible pipelines. Check this script for details
155
+
156
+
157
+ Note: for the real shot images testing, you have to:
158
+
159
+ 1. save the real-shot image as a readable raw image (like in .RAW, .ARW, .DNG format). For example, we use Lightroom mobile version to shot images on iPhone and save the photo in .DNG format.
160
+ 2. Read the general metadata using RawPy and read the noise profiling metadata using [Jeffrey's Image Metadata Viewer](http://exif.regex.info/exif.cgi) or [metapicz](http://metapicz.com/).
161
+
162
+
163
+
164
+ ## Result
165
+ <p align="center">
166
+ <img width="800" src="misc/pipeline_result.png">
167
+ </p>
168
+
169
+
170
+ ### Citation
171
+
172
+ Please cite the following paper if you feel TENet and PixelShift200 is useful to your research
173
+
174
+ ```
175
+ @article{qian2019rethink,
176
+ title={Rethink the Pipeline of Demosaicking, Denoising, and Super-resolution},
177
+ author={Qian, Guocheng and Wang, Yuanhao and Gu, Jinjin and Dong, Chao and Heidrich, Wolfgang and Ghanem, Bernard and Ren, Jimmy S},
178
+ journal={arXiv preprint arXiv:1905.02538},
179
+ year={2019}
180
+ }
181
+ ```
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tenet_official"
7
+ version = "0.1.0"
8
+ description = "TENet (ICCP'22) release metadata and resource helpers for pip users: paper, PixelShift200 dataset, model list, and pretrained-weight loading info."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = "MIT"
12
+ authors = [{ name = "Guocheng Qian" }]
13
+ keywords = ["demosaicing", "denoising", "super-resolution", "ISP", "raw", "pytorch", "TENet", "PixelShift200"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Science/Research",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Programming Language :: Python :: 3.8",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ "Topic :: Scientific/Engineering :: Image Processing",
26
+ ]
27
+ dependencies = []
28
+
29
+ [project.optional-dependencies]
30
+ dev = ["build>=1", "twine>=4", "pytest>=7"]
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/guochengqian/TENet"
34
+ Repository = "https://github.com/guochengqian/TENet"
35
+ Paper = "https://arxiv.org/abs/1905.02538"
36
+ Dataset = "http://guochengqian.github.io/project/pixelshift200"
37
+
38
+ [project.scripts]
39
+ tenet-info = "tenet_official.cli:main"
40
+
41
+ [tool.setuptools]
42
+ packages = ["tenet_official"]
43
+ zip-safe = false
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,30 @@
1
+ """TENet release helper package.
2
+
3
+ TENet (ICCP'22) — *Rethinking Learning-based Demosaicing, Denoising, and
4
+ Super-Resolution Pipeline*. The research training/evaluation code lives in the
5
+ TENet repository. This small package provides stable metadata, resource links,
6
+ and helpers for pip-installed users (paper, PixelShift200 dataset, pretrained
7
+ weights, and the model list).
8
+ """
9
+
10
+ from .info import (
11
+ ARXIV_URL,
12
+ PIXELSHIFT200,
13
+ PROJECT_PAGE,
14
+ REPOSITORY,
15
+ MODELS,
16
+ RESOURCES,
17
+ resources,
18
+ )
19
+
20
+ __all__ = [
21
+ "ARXIV_URL",
22
+ "PIXELSHIFT200",
23
+ "PROJECT_PAGE",
24
+ "REPOSITORY",
25
+ "MODELS",
26
+ "RESOURCES",
27
+ "resources",
28
+ ]
29
+
30
+ __version__ = "0.1.0"
@@ -0,0 +1,51 @@
1
+ """Command-line helper for the tenet_official package.
2
+
3
+ Prints TENet resource links (paper, code, PixelShift200 dataset) so pip users
4
+ can quickly find where to get the code, data, and how weights are loaded.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import argparse
10
+
11
+ from . import __version__
12
+ from .info import MODELS, RESOURCES, REPOSITORY
13
+
14
+
15
+ def build_parser() -> argparse.ArgumentParser:
16
+ parser = argparse.ArgumentParser(
17
+ description="TENet resource/info helper (paper, code, PixelShift200 dataset)."
18
+ )
19
+ parser.add_argument("--models", action="store_true", help="List available model variants and exit.")
20
+ parser.add_argument("--version", action="store_true", help="Print version and exit.")
21
+ return parser
22
+
23
+
24
+ def main(argv: list[str] | None = None) -> int:
25
+ parser = build_parser()
26
+ args = parser.parse_args(argv)
27
+
28
+ if args.version:
29
+ print(__version__)
30
+ return 0
31
+
32
+ if args.models:
33
+ print("TENet model variants (model/<name>.py, built as model.<name>.Net(args)):")
34
+ for name in MODELS:
35
+ print(f" - {name}")
36
+ return 0
37
+
38
+ print(f"TENet (tenet_official {__version__})")
39
+ print("Rethinking Learning-based Demosaicing, Denoising, and Super-Resolution Pipeline\n")
40
+ for res in RESOURCES.values():
41
+ print(f" {res.key:14s} {res.url}\n {'':14s} {res.description}")
42
+ print(
43
+ "\nTraining/evaluation uses a source checkout — see "
44
+ f"{REPOSITORY} (`source install.sh`).\n"
45
+ "Pretrained weights are passed via `--pretrain /path/to/checkpoint.pth`."
46
+ )
47
+ return 0
48
+
49
+
50
+ if __name__ == "__main__": # pragma: no cover
51
+ raise SystemExit(main())
@@ -0,0 +1,65 @@
1
+ """Stable metadata and resource links for TENet.
2
+
3
+ TENet is a research codebase (training/evaluation scripts), not a library, so
4
+ this package intentionally ships metadata + resource pointers rather than
5
+ importable model code. Use a source checkout of the repository to train/evaluate.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from dataclasses import dataclass, field
11
+ from typing import Dict, List
12
+
13
+ ARXIV_URL = "https://arxiv.org/abs/1905.02538"
14
+ PROJECT_PAGE = "http://guochengqian.github.io/project/pixelshift200"
15
+ REPOSITORY = "https://github.com/guochengqian/TENet"
16
+
17
+
18
+ @dataclass(frozen=True)
19
+ class Resource:
20
+ """A named external resource with a URL and short description."""
21
+
22
+ key: str
23
+ url: str
24
+ description: str
25
+
26
+
27
+ # PixelShift200 dataset. The .mat files are 4-channel (R, Gr, Gb, B) full-color
28
+ # captures produced by pixel-shift photography; original RAW (.ARW) files are
29
+ # also provided. See the project page for details.
30
+ PIXELSHIFT200: Dict[str, str] = {
31
+ "project_page": PROJECT_PAGE,
32
+ "google_drive": "https://drive.google.com/drive/folders/1S1mt9D8IlpSAVm7RTjLheh1hTaltsV_f?usp=share_link",
33
+ }
34
+
35
+
36
+ # TENet model variants available in the `model/` package of the repository
37
+ # (built via `importlib.import_module("model.<name>").Net(args)`).
38
+ MODELS: List[str] = [
39
+ "tenet",
40
+ "tenetv0",
41
+ "tenetv2",
42
+ "tenetv3",
43
+ "jdndmsr",
44
+ "jdndmsr_e2e",
45
+ "jdsr",
46
+ "resnet",
47
+ ]
48
+
49
+
50
+ RESOURCES: Dict[str, Resource] = {
51
+ "paper": Resource("paper", ARXIV_URL, "TENet paper (arXiv:1905.02538, ICCP'22)"),
52
+ "code": Resource("code", REPOSITORY, "Training/evaluation source code"),
53
+ "project": Resource("project", PROJECT_PAGE, "PixelShift200 project page"),
54
+ "pixelshift200": Resource(
55
+ "pixelshift200",
56
+ PIXELSHIFT200["google_drive"],
57
+ "PixelShift200 dataset + original RAW files (Google Drive)",
58
+ ),
59
+ }
60
+
61
+
62
+ def resources() -> Dict[str, Resource]:
63
+ """Return the known TENet resources keyed by short name."""
64
+
65
+ return dict(RESOURCES)
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: tenet_official
3
+ Version: 0.1.0
4
+ Summary: TENet (ICCP'22) release metadata and resource helpers for pip users: paper, PixelShift200 dataset, model list, and pretrained-weight loading info.
5
+ Author: Guocheng Qian
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/guochengqian/TENet
8
+ Project-URL: Repository, https://github.com/guochengqian/TENet
9
+ Project-URL: Paper, https://arxiv.org/abs/1905.02538
10
+ Project-URL: Dataset, http://guochengqian.github.io/project/pixelshift200
11
+ Keywords: demosaicing,denoising,super-resolution,ISP,raw,pytorch,TENet,PixelShift200
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Provides-Extra: dev
27
+ Requires-Dist: build>=1; extra == "dev"
28
+ Requires-Dist: twine>=4; extra == "dev"
29
+ Requires-Dist: pytest>=7; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # TENet <a href="https://arxiv.org/abs/1905.02538" target="_blank">[ArXiv]</a> <a href="http://guochengqian.github.io/project/pixelshift200">[pixelshift200]</a>
33
+
34
+ ### Rethinking Learning-based Demosaicing, Denoising, and Super-Resolution Pipeline
35
+ By [Guocheng Qian*](https://guochengqian.github.io/), [Yuanhao Wang*](https://github.com/yuanhaowang1213), [Jinjin Gu](http://www.jasongt.com/), Chao Dong, Wolfgang Heidrich, Bernard Ghanem, [Jimmy S. Ren](http://www.jimmyren.com/)
36
+
37
+ The original name of this project is: "Trinity of Pixel Enhancement: a Joint Solution for Demosaicking, Denoising and Super-Resolution"
38
+
39
+
40
+
41
+ ## TENet
42
+
43
+ We insert the proposed pipeline DN -> SR -> DM into an end-to-end network constructed by RRDB for the joint DN, DM and SR. We leverage the detachable branch to provide the middle stage supervision.
44
+
45
+
46
+ <p align="center">
47
+ <img height="300" src="misc/Network.png">
48
+ </p>
49
+
50
+
51
+
52
+
53
+ ## PixelShift200 dataset
54
+
55
+ We employ advanced pixel shift technology to perform a full color sampling of the image.
56
+ Pixel shift technology takes four samples of the same image, and physically controls the camera sensor to move one pixel horizontally or vertically at each sampling to capture all color information at each pixel.
57
+ The pixel shift technology ensures that the sampled images follow the distribution of natural images sampled by the camera, and the full information of the color is completely obtained.
58
+ In this way, the collected images are artifacts-free, which leads to better training results for demosaicing related tasks.
59
+
60
+ <p align="center">
61
+ <img height="200" src="misc/PixelShift.png">
62
+ </p>
63
+
64
+
65
+ Download PixelShift200 and the original RAW files from [pxielshift200 website](http://guochengqian.github.io/project/pixelshift200) for using this [Google Drive Link](https://drive.google.com/drive/folders/1S1mt9D8IlpSAVm7RTjLheh1hTaltsV_f?usp=share_link)
66
+
67
+
68
+ ### Environment installation
69
+
70
+ Clone this github repo and install the environment by:
71
+
72
+ ```bash
73
+ git clone https://github.com/guochengqian/TENet
74
+ cd TENet
75
+ source install.sh
76
+ conda activate tenet
77
+ ```
78
+
79
+
80
+
81
+ ### Data preparation
82
+
83
+ 1. synthetic data preparation [Optional]
84
+ Processing synthetic dataset if you are interested in synthetic benchmark.
85
+ 1. Download ([DIV2K](https://drive.google.com/file/d/1vXPPr2hVaMewz2JA1lFfI5uHB4ENwRXQ/view?usp=sharing)) dataset
86
+
87
+ 2. `mkdir data && cd data`
88
+
89
+ 3. Link DIV2K data into ./data/DIV2K, e.g. `ln -s /data/lowlevel/DIV2K ./`
90
+
91
+ 4. Crop DIV2K
92
+
93
+ ```bash
94
+ cd ../datasets
95
+ python crop_imgs.py # crop train images
96
+ python crop_imgs.py --src_dir ../data/DIV2K/DIV2K_val5_HR --save_dir ../data/DIV2K/DIV2K_val5_HR_sub # crop val5 images
97
+ ```
98
+
99
+ 2. PixelShift200 data preparation
100
+ Processing PixelShift200 dataset if you are interested in PixelShift200 benchmark.
101
+ 1. Download [Pixelshift200](http://guochengqian.com/pixelshift200). They are .mat format, having 4 channels (R, Gr, Gb, B). Unzip the .zip file and put all folders inside into one folder called pixelshift200. For example, put here `/data/lowlevel/pixelshift200`.
102
+
103
+ 2. `cd TENet && mkdir data && cd data`
104
+
105
+ 3. Link PixelShift200 data into ./data/pixelshift200, e.g. `ln -s /data/lowlevel/pixelshift200 pixelshift200`
106
+
107
+ 4. Crop images into 512*512, and generate the text file that contains the location of each image:
108
+
109
+ ```bash
110
+ cd ../datasets
111
+ python crop_pixelshift200.py
112
+ python generate_datalist_pixelshift.py
113
+ ```
114
+
115
+
116
+ ## Training
117
+ #### Train joint models
118
+
119
+ * DN+SR->DM (our **TENet**)
120
+
121
+ ```bash
122
+ python train.py --in_type noisy_lr_raw --mid_type raw --out_type linrgb --model tenet --n_gpus 4 --block rrdb --n_blocks 12
123
+ ```
124
+
125
+ * DN+DM+SR [Optional] (baseline: end to end without pipeline)
126
+
127
+ ```bash
128
+ python train.py --in_type noisy_lr_raw --mid_type None --out_type linrgb --model tenet --n_gpus 4 --block rrdb --n_blocks 12
129
+ ```
130
+
131
+ Note:
132
+
133
+ 1. `--mid_type raw` is to activate the auxiliary mid stage supervision. Here we add `raw` as the supervision, therefore, the pipeline will be DN+SR->DM
134
+
135
+ 2. for training on a different dataset, like DIV2K, change `--dataset div2k`
136
+
137
+ 3. for training with Gaussian noise model, add `--noise_model g`
138
+
139
+ 4. for using a different building block, such as NLSA `--block nlsa`, or EAM `--block eam` , or RRG `--block rrg`, or DRLM `--block drlm` or RRDB `--block rrdb`
140
+
141
+ 5. [`wandb`](https://wandb.ai/) is used by default. Set `--no_wandb` to not using wandb
142
+
143
+
144
+
145
+ #### Train sequential models [Optional] (ablation study)
146
+
147
+ ```bash
148
+ # RawDN
149
+ python train.py --in_type noisy_raw --out_type raw --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
150
+
151
+ # RawSR
152
+ python train.py --in_type lr_raw --out_type raw --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
153
+
154
+ # DM
155
+ python train.py --in_type raw --out_type linrgb --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
156
+
157
+ # RGBDN
158
+ python train.py --in_type noisy_linrgb --out_type linrgb --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
159
+
160
+ # RGBSR
161
+ python train.py --in_type lr_linrgb --out_type linrgb --model resnet --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block rrdb --n_blocks 12
162
+ ```
163
+
164
+
165
+ ### Train SOTA models [Optional]
166
+ We also support training previous work.
167
+
168
+ * JDSR
169
+ ```bash
170
+ python train.py --in_type noisy_lr_raw --mid_type None --out_type linrgb --model jdsr --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --use_wandb --block res --n_blocks 12 --channels 256
171
+ ```
172
+
173
+ * JDnDmSR
174
+
175
+ ```bash
176
+ python train.py --in_type noisy_lr_raw --mid_type lr_raw --out_type linrgb --model jdndmsr --scale 2 --train_list datasets/train_pixelshift.txt --val_list datasets/val_pixelshift.txt --n_gpus 4 --n_blocks 2 --block rcab
177
+ ```
178
+
179
+
180
+ ## Testing
181
+
182
+ ```bash
183
+ bash script_all_pipelines.sh
184
+ ```
185
+ This script supports evaluation on all benchmarking datasets as well as the real-shot images for all possible pipelines. Check this script for details
186
+
187
+
188
+ Note: for the real shot images testing, you have to:
189
+
190
+ 1. save the real-shot image as a readable raw image (like in .RAW, .ARW, .DNG format). For example, we use Lightroom mobile version to shot images on iPhone and save the photo in .DNG format.
191
+ 2. Read the general metadata using RawPy and read the noise profiling metadata using [Jeffrey's Image Metadata Viewer](http://exif.regex.info/exif.cgi) or [metapicz](http://metapicz.com/).
192
+
193
+
194
+
195
+ ## Result
196
+ <p align="center">
197
+ <img width="800" src="misc/pipeline_result.png">
198
+ </p>
199
+
200
+
201
+ ### Citation
202
+
203
+ Please cite the following paper if you feel TENet and PixelShift200 is useful to your research
204
+
205
+ ```
206
+ @article{qian2019rethink,
207
+ title={Rethink the Pipeline of Demosaicking, Denoising, and Super-resolution},
208
+ author={Qian, Guocheng and Wang, Yuanhao and Gu, Jinjin and Dong, Chao and Heidrich, Wolfgang and Ghanem, Bernard and Ren, Jimmy S},
209
+ journal={arXiv preprint arXiv:1905.02538},
210
+ year={2019}
211
+ }
212
+ ```
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ tenet_official/__init__.py
5
+ tenet_official/cli.py
6
+ tenet_official/info.py
7
+ tenet_official.egg-info/PKG-INFO
8
+ tenet_official.egg-info/SOURCES.txt
9
+ tenet_official.egg-info/dependency_links.txt
10
+ tenet_official.egg-info/entry_points.txt
11
+ tenet_official.egg-info/not-zip-safe
12
+ tenet_official.egg-info/requires.txt
13
+ tenet_official.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ tenet-info = tenet_official.cli:main
@@ -0,0 +1,5 @@
1
+
2
+ [dev]
3
+ build>=1
4
+ twine>=4
5
+ pytest>=7
@@ -0,0 +1 @@
1
+ tenet_official