Skip to content

Commit e545b2f

Browse files
committed
update demo.py to allow save intermediate results
1 parent cf722f6 commit e545b2f

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ python demo.py
3737

3838
The ISP outputs will be saved to `./output` directory.
3939

40-
The only required package for pipeline execution is `numpy`.
41-
42-
`opencv-python` and `scikit-image` are required for data IO.
40+
The only required package for pipeline execution is `numpy`. `opencv-python` and `scikit-image` are required only for
41+
data IO.
4342

4443
# Algorithms
4544

demo.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
from utils.yacs import Config
1010

1111

12-
output_dir = './output'
13-
os.makedirs(output_dir, exist_ok=True)
12+
OUTPUT_DIR = './output'
13+
os.makedirs(OUTPUT_DIR, exist_ok=True)
1414

1515

1616
def demo_test_raw():
17-
print('Processing test raw started')
18-
1917
cfg = Config('configs/test.yaml')
2018
pipeline = Pipeline(cfg)
2119

@@ -25,14 +23,12 @@ def demo_test_raw():
2523

2624
data, _ = pipeline.execute(bayer)
2725

28-
output_path = op.join(output_dir, 'test.png')
26+
output_path = op.join(OUTPUT_DIR, 'test.png')
2927
output = cv2.cvtColor(data['output'], cv2.COLOR_RGB2BGR)
3028
cv2.imwrite(output_path, output)
3129

3230

3331
def demo_nikon_d3x():
34-
print('\nProcessing Nikon D3x raw started')
35-
3632
cfg = Config('configs/nikon_d3x.yaml')
3733
pipeline = Pipeline(cfg)
3834

@@ -41,11 +37,43 @@ def demo_nikon_d3x():
4137

4238
data, _ = pipeline.execute(bayer)
4339

44-
output_path = op.join(output_dir, 'color_checker.png')
40+
output_path = op.join(OUTPUT_DIR, 'color_checker.png')
4541
output = cv2.cvtColor(data['output'], cv2.COLOR_RGB2BGR)
4642
cv2.imwrite(output_path, output)
4743

4844

45+
def demo_intermediate_results():
46+
cfg = Config('configs/nikon_d3x.yaml')
47+
48+
# Boost parameters for exaggeration effect
49+
with cfg.unfreeze():
50+
cfg.module_enable_status.nlm = True
51+
cfg.nlm.h = 15
52+
cfg.eeh.flat_threshold = 1
53+
cfg.eeh.flat_threshold = 2
54+
cfg.eeh.edge_gain = 1280
55+
cfg.hsc.saturation_gain = 384
56+
cfg.bcc.contrast_gain = 300
57+
58+
pipeline = Pipeline(cfg)
59+
60+
pgm_path = 'raw/color_checker.pgm'
61+
bayer = skimage.io.imread(pgm_path).astype(np.uint16)
62+
63+
_, intermediates = pipeline.execute(bayer, save_intermediates=True)
64+
for module_name, result in intermediates.items():
65+
output = pipeline.get_output(result)
66+
output_path = op.join(OUTPUT_DIR, '{}.jpg'.format(module_name))
67+
output = cv2.cvtColor(output, cv2.COLOR_RGB2BGR)
68+
cv2.imwrite(output_path, output)
69+
70+
4971
if __name__ == '__main__':
72+
print('Processing test raw...')
5073
demo_test_raw()
74+
75+
print('Processing Nikon D3x raw...')
5176
demo_nikon_d3x()
77+
78+
print('Processing Nikon D3x raw with intermediate results...')
79+
demo_intermediate_results()

0 commit comments

Comments
 (0)