Revert to no image slider :-(
Browse files
app.py
CHANGED
|
@@ -1,20 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
import flip
|
| 4 |
-
from gradio_imageslider import ImageSlider
|
| 5 |
|
| 6 |
-
|
| 7 |
-
def compute_simple_diff(imgs: tuple[np.array, np.array]) -> (np.array, float):
|
| 8 |
'''compute difference of two arrays'''
|
| 9 |
-
return
|
| 10 |
|
| 11 |
|
| 12 |
-
def compute_flip_diff(
|
| 13 |
'''
|
| 14 |
compute NVIDIA nvlab's FLIP difference between two image arrays
|
| 15 |
'''
|
| 16 |
-
error_map,
|
| 17 |
-
return error_map
|
| 18 |
|
| 19 |
|
| 20 |
examples = [
|
|
@@ -24,18 +22,22 @@ examples = [
|
|
| 24 |
|
| 25 |
with gr.Blocks() as demo:
|
| 26 |
gr.Markdown("Compute difference using NVIDIA's [FLIP](https://github.com/NVlabs/flip/)")
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
button.click(fn=compute_flip_diff,
|
| 35 |
-
inputs=
|
| 36 |
-
outputs=[diff]
|
| 37 |
)
|
| 38 |
-
|
| 39 |
|
| 40 |
if __name__ == "__main__":
|
| 41 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
import flip
|
|
|
|
| 4 |
|
| 5 |
+
def compute_simple_diff(a: np.array, b: np.array) -> (np.array, float):
|
|
|
|
| 6 |
'''compute difference of two arrays'''
|
| 7 |
+
return a - b, str(np.round(np.mean(a-b), 4))
|
| 8 |
|
| 9 |
|
| 10 |
+
def compute_flip_diff(a: np.array, b: np.array) -> (np.array, float):
|
| 11 |
'''
|
| 12 |
compute NVIDIA nvlab's FLIP difference between two image arrays
|
| 13 |
'''
|
| 14 |
+
error_map, mean_error, _ = flip.evaluate(a, b, "HDR")
|
| 15 |
+
return error_map, str(np.round(mean_error,4))
|
| 16 |
|
| 17 |
|
| 18 |
examples = [
|
|
|
|
| 22 |
|
| 23 |
with gr.Blocks() as demo:
|
| 24 |
gr.Markdown("Compute difference using NVIDIA's [FLIP](https://github.com/NVlabs/flip/)")
|
| 25 |
+
with gr.Row(equal_height=True):
|
| 26 |
+
# define inputs and outputs
|
| 27 |
+
before = gr.Image(label="Before")
|
| 28 |
+
after = gr.Image(label="After")
|
| 29 |
+
diff = gr.Image(label="Difference")
|
| 30 |
+
with gr.Row(equal_height=True):
|
| 31 |
+
with gr.Column(scale=2):
|
| 32 |
+
button = gr.Button("Compute difference")
|
| 33 |
+
with gr.Column(scale=1, min_width=200):
|
| 34 |
+
meanbox = gr.Textbox(label="Mean difference")
|
| 35 |
+
# interaction
|
| 36 |
button.click(fn=compute_flip_diff,
|
| 37 |
+
inputs=[before, after],
|
| 38 |
+
outputs=[diff, meanbox]
|
| 39 |
)
|
| 40 |
+
gr.Examples(examples, [before, after])
|
| 41 |
|
| 42 |
if __name__ == "__main__":
|
| 43 |
demo.launch()
|