Spaces:
Sleeping
Sleeping
kargaranamir
commited on
Commit
·
4c11801
1
Parent(s):
2ce3017
Add application file
Browse files- app.py +32 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch
|
3 |
+
|
4 |
+
torch.hub.download_url_to_file('https://github.com/kargaranamir/visual-clutter/raw/main/tests/test.jpg', 'test.jpg')
|
5 |
+
torch.hub.download_url_to_file('https://github.com/kargaranamir/visual-clutter/raw/main/tests/test2.jpg', 'test2.jpg')
|
6 |
+
|
7 |
+
|
8 |
+
def inference(img):
|
9 |
+
clt = Vlc(img.name, numlevels=3, contrast_filt_sigma=1, contrast_pool_sigma=3, color_pool_sigma=3, prefix='test')
|
10 |
+
# get Feature Congestion clutter of a test map:
|
11 |
+
clutter_scalar_fc, clutter_map_fc = clt.getClutter_FC(p=1, pix=1)
|
12 |
+
# get Subband Entropy clutter of the test map:
|
13 |
+
# clutter_scalar_se = clt.getClutter_SE(wlevels=3, wght_chrom=0.0625)
|
14 |
+
return ['test_collapsed combine map.png']
|
15 |
+
|
16 |
+
title = 'Visual Clutter'
|
17 |
+
description = 'Compute two measures of visual clutter (Feature Congestion and Subband Entropy)'
|
18 |
+
article = "<p style='text-align: center'></p>"
|
19 |
+
examples = [['test.jpg'],['test2.jpg']]
|
20 |
+
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
21 |
+
|
22 |
+
gr.Interface(
|
23 |
+
inference,
|
24 |
+
[gr.inputs.Image(type='file', label='Input')],
|
25 |
+
[gr.outputs.Image(type='file', label='Output')],
|
26 |
+
title=title,
|
27 |
+
description=description,
|
28 |
+
article=article,
|
29 |
+
examples=examples,
|
30 |
+
css=css,
|
31 |
+
enable_queue=True
|
32 |
+
).launch(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
gradio
|
3 |
+
visual-clutter==1.0
|