Luis Oala commited on
Commit
a1d6a9c
·
1 Parent(s): 61992ab
Files changed (2) hide show
  1. app.py +2 -2
  2. app.py~ +54 -0
app.py CHANGED
@@ -49,6 +49,6 @@ iface = gr.Interface(
49
  title="static pipeline demo",
50
  description="You can select a sample raw image, the camera parameters and the pipeline configuration to process the raw image.")
51
 
52
- if __name__ == "__main__":
53
- iface.launch(share=True)
54
 
 
49
  title="static pipeline demo",
50
  description="You can select a sample raw image, the camera parameters and the pipeline configuration to process the raw image.")
51
 
52
+ #if __name__ == "__main__":
53
+ iface.launch(share=True)
54
 
app.py~ ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ #import tensorflow as tf
3
+ import numpy as np
4
+ import json
5
+ from os.path import dirname, realpath, join
6
+ import processing.pipeline_numpy as ppn
7
+
8
+
9
+ # Load human-readable labels for ImageNet.
10
+ current_dir = dirname(realpath(__file__))
11
+
12
+
13
+ def process(RawImage, CameraParameters, Debayer, Sharpening, Denoising):
14
+ raw_img = RawImage
15
+ if CameraParameters == "Microscope":
16
+ black_level = [9.834368023181512e-06, 9.834368023181512e-06, 9.834368023181512e-06, 9.834368023181512e-06]
17
+ white_balance = [-0.6567, 1.9673, 3.5304]
18
+ colour_matrix = [-2.0338, 0.0933, 0.4157, -0.0286, 2.6464, -0.0574, -0.5516, -0.0947, 2.9308]
19
+ elif CameraParameters == "Drone":
20
+ #drone
21
+ black_level = [0.0625, 0.0626, 0.0625, 0.0626]
22
+ white_balance = [2.86653646, 1., 1.73079425]
23
+ colour_matrix = [1.50768983, -0.33571374, -0.17197604, -0.23048614,
24
+ 1.70698738, -0.47650126, -0.03119153, -0.32803956, 1.35923111]
25
+ else:
26
+ print("No valid camera parameter")
27
+ debayer = Debayer
28
+ sharpening = Sharpening
29
+ denoising = Denoising
30
+ print(np.max(raw_img))
31
+ raw_img = (raw_img[:,:,0].astype(np.float64)/255.)
32
+ img = ppn.processing(raw_img, black_level, white_balance, colour_matrix,
33
+ debayer=debayer, sharpening=sharpening, denoising=denoising)
34
+ print(np.max(img))
35
+ return img
36
+
37
+
38
+ iface = gr.Interface(
39
+ process,
40
+ [gr.inputs.Image(),gr.inputs.Radio(["Microscope", "Drone"]),gr.inputs.Dropdown(["bilinear", "malvar2004", "menon2007"]),
41
+ gr.inputs.Dropdown(["sharpening_filter", "unsharp_masking"]),
42
+ gr.inputs.Dropdown(["gaussian_denoising", "median_denoising"])],
43
+ "image",
44
+ capture_session=True,
45
+ examples=[
46
+ ["demo-files/car.png"],
47
+ ["demo-files/micro.png"]
48
+ ],
49
+ title="static pipeline demo",
50
+ description="You can select a sample raw image, the camera parameters and the pipeline configuration to process the raw image.")
51
+
52
+ if __name__ == "__main__":
53
+ iface.launch(share=True)
54
+