Spaces:
Sleeping
Sleeping
| 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) | |