File size: 1,262 Bytes
4c11801
 
7e83504
4c11801
5473cc1
 
4c11801
 
 
c79cf7a
dd5bd34
4c11801
 
999b0bd
4c11801
861d8fa
4c11801
 
 
 
88350a3
 
4c11801
 
 
 
 
5473cc1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
import torch
from visual_clutter import Vlc

def inference(img_path):
    clt = Vlc(img_path, numlevels=3, contrast_filt_sigma=1, contrast_pool_sigma=3, color_pool_sigma=3, prefix='test')
    # get Feature Congestion clutter of a test map:
    clutter_scalar_fc, clutter_map_fc = clt.getClutter_FC(p=1, pix=1)
    # get Subband Entropy clutter of the test map:
    clutter_scalar_se = clt.getClutter_SE(wlevels=3, wght_chrom=0.0625)
    return ['test_collapsed_combine_map.png', str(clutter_scalar_fc), str(clutter_scalar_se)]

title = 'Visual Clutter'
description = 'Compute two measures of visual clutter (Feature Congestion and Subband Entropy), see the code at https://github.com/kargaranamir/visual-clutter'
article = "<p style='text-align: center'></p>"
examples = [['test.jpg'], ['test2.jpg']]
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"

gr.Interface(
    inference,
    [gr.Image(type='filepath', label='Input')],
    [gr.Image(type='filepath', label='Feature Congestion Output Image'), gr.Textbox(label="Feature Congestion"), gr.Textbox(label="Subband Entropy")],
    title=title,
    description=description,
    article=article,
    examples=examples,
    css=css,
).launch(debug=True)