File size: 1,262 Bytes
4c11801
 
7e83504
4c11801
 
 
 
 
 
 
c79cf7a
dd5bd34
4c11801
 
 
 
 
 
 
 
 
 
d822af7
4c11801
 
 
 
 
e44cce4
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):
    clt = Vlc(img.name, 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)'
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.inputs.Image(type='file', label='Input')],
    [gr.outputs.Image(type='file', label='Feature Congestion Output Image'), gr.outputs.Textbox(type="str", label="Feature Congestion"), gr.outputs.Textbox(type="str", label="Subband Entorpy")],
    title=title,
    description=description,
    article=article,
    examples=examples,
    css=css,
    ).launch(debug=True, enable_queue=True)