Spaces:
Running
Running
mischeiwiller
commited on
Commit
•
4e02b75
1
Parent(s):
253f253
Update app.py
Browse files
app.py
CHANGED
@@ -29,11 +29,17 @@ def predict(images, eps):
|
|
29 |
grid_zca = make_grid(zca_images, nrow=3, normalize=True).cpu().numpy()
|
30 |
return np.transpose(grid_zca, [1, 2, 0])
|
31 |
|
|
|
|
|
|
|
32 |
title = 'ZCA Whitening with Kornia!'
|
33 |
description = '''[ZCA Whitening](https://paperswithcode.com/method/zca-whitening) is an image preprocessing method that leads to a transformation of data such that the covariance matrix is the identity matrix, leading to decorrelated features:
|
34 |
*Note that you can upload only image files, e.g. jpg, png etc and there should be at least 2 images!*
|
35 |
Learn more about [ZCA Whitening and Kornia](https://kornia.readthedocs.io/en/latest/enhance.zca.html)'''
|
36 |
|
|
|
|
|
|
|
37 |
with gr.Blocks(title=title) as demo:
|
38 |
gr.Markdown(f"# {title}")
|
39 |
gr.Markdown(description)
|
@@ -47,16 +53,10 @@ with gr.Blocks(title=title) as demo:
|
|
47 |
submit_button = gr.Button("Apply ZCA Whitening")
|
48 |
submit_button.click(fn=predict, inputs=[input_images, eps_slider], outputs=output_image)
|
49 |
|
50 |
-
gr.
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
'tulips.jpg', 'Alstroemeria.jpg', 'Carnation.jpg', 'Orchid.jpg', 'Peony.jpg'],
|
55 |
-
0.01
|
56 |
-
]
|
57 |
-
],
|
58 |
-
inputs=[input_images, eps_slider],
|
59 |
-
)
|
60 |
|
61 |
if __name__ == "__main__":
|
62 |
demo.launch(show_error=True)
|
|
|
29 |
grid_zca = make_grid(zca_images, nrow=3, normalize=True).cpu().numpy()
|
30 |
return np.transpose(grid_zca, [1, 2, 0])
|
31 |
|
32 |
+
def load_example_images(example_images):
|
33 |
+
return example_images
|
34 |
+
|
35 |
title = 'ZCA Whitening with Kornia!'
|
36 |
description = '''[ZCA Whitening](https://paperswithcode.com/method/zca-whitening) is an image preprocessing method that leads to a transformation of data such that the covariance matrix is the identity matrix, leading to decorrelated features:
|
37 |
*Note that you can upload only image files, e.g. jpg, png etc and there should be at least 2 images!*
|
38 |
Learn more about [ZCA Whitening and Kornia](https://kornia.readthedocs.io/en/latest/enhance.zca.html)'''
|
39 |
|
40 |
+
example_images = ['irises.jpg', 'roses.jpg', 'sunflower.jpg', 'violets.jpg', 'chamomile.jpg',
|
41 |
+
'tulips.jpg', 'Alstroemeria.jpg', 'Carnation.jpg', 'Orchid.jpg', 'Peony.jpg']
|
42 |
+
|
43 |
with gr.Blocks(title=title) as demo:
|
44 |
gr.Markdown(f"# {title}")
|
45 |
gr.Markdown(description)
|
|
|
53 |
submit_button = gr.Button("Apply ZCA Whitening")
|
54 |
submit_button.click(fn=predict, inputs=[input_images, eps_slider], outputs=output_image)
|
55 |
|
56 |
+
gr.Markdown("## Example Images")
|
57 |
+
example_gallery = gr.Gallery(value=example_images, label="Example Images", columns=5, height="auto")
|
58 |
+
load_examples_button = gr.Button("Load Example Images")
|
59 |
+
load_examples_button.click(fn=load_example_images, inputs=[example_gallery], outputs=[input_images])
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
if __name__ == "__main__":
|
62 |
demo.launch(show_error=True)
|