Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from input_manager import run_inference, latest_conf_matrix, latest_labels | |
| import pandas as pd | |
| color_map_dict = { | |
| "Dictyopteris polypodioides": "#FF5733", | |
| "Zonaria tournefortii": "#DAF7A6", | |
| "Peyssonnelia sp.": "#581845", | |
| "Sargassum vulgare": "#C70039", | |
| "Crambe crambe": "#FFC300", | |
| "Stones and Pebbles": "#900C3F", | |
| "Sand": "#FF5733", | |
| "Scalarispongia scalaris": "#DAF7A6", | |
| "Jania rubens": "#581845", | |
| "Hard bed and rock": "#C70039", | |
| "Hermodice carunculata": "#FFC300", | |
| "Posidonia oceanica": "#900C3F", | |
| "Coarse sand": "#58D68D", | |
| "Sarcotragus spinosulus": "#E74C3C", | |
| "Centrostephanus longispinus": "#2E86C1", | |
| "CCS": "#7D3C98", | |
| "Protula sp.": "#B03A2E", | |
| "Lithophyllum incrustans": "#2874A6", | |
| "Halophila stipulacea": "#239B56", | |
| "Asparagopsis taxiformis": "#D35400", | |
| "Padina pavonica": "#7E5109", | |
| "Cymodocea nodosa": "#1E8449", | |
| "Liagora viscida": "#9A7D0A", | |
| "Lophocladia lallemandii": "#1ABC9C", | |
| "Dictyota dichotoma": "#D98880", | |
| "Chondrilla nucula": "#FAD7A0", | |
| "Ulva compressa": "#D7BDE2" | |
| } | |
| iface = gr.Interface( | |
| fn=run_inference, | |
| inputs=[gr.Image(label="Image to Evaluate"), | |
| gr.Dropdown(label="Depth",choices=["Unknown","Less than 30m","Less than 90m","Less than 150m"], value="Unknown"), | |
| gr.Textbox(label="CSV Input (Paste CSV Contents Here)", lines=10, value='''Species Present,Seagrasses,Algal Communities,Biogenic reef,Coarse Sand,Rock | |
| Posidonia oceanica,100,0,0,0,0 | |
| Cymodocea nodosa,100,0,0,0,0 | |
| Asparagopsis taxiformis,0,80,20,0,0 | |
| Liagora viscida,0,80,20,0,0 | |
| Lophocladia lallemandii,30,60,10,0,0 | |
| Peyssonnelia sp.,0,10,50,0,40 | |
| Lithophyllum incrustans,0,0,70,0,30 | |
| Jania rubens,0,90,10,0,0 | |
| Codium bursa,0,50,20,10,20 | |
| Ulva compressa,0,50,30,0,20 | |
| Dictyopteris polypodioides,0,60,30,0,10 | |
| Dictyota dichotoma,0,60,20,0,20 | |
| Padina pavonica,0,40,20,20,20 | |
| Sargassum vulgare,0,70,10,10,10 | |
| Zonaria tournefortii,0,60,30,0,10 | |
| Chondrilla nucula,0,0,90,0,10 | |
| Sarcotragus spinosulus,0,10,70,0,20 | |
| Scalarispongia scalaris,0,10,70,0,20 | |
| Hermodice carunculata,10,10,40,10,30 | |
| Centrostephanus longispinus,0,0,50,0,50 | |
| Crambe crambe,0,0,50,0,50 | |
| Protula sp.,0,0,50,0,50 | |
| Sand,0,0,0,100,0 | |
| Hard bed and rock,0,0,0,0,100 | |
| Stones and Pebbles,0,0,0,0,20 | |
| Maximum Depth,40,90,90,150,150''')], | |
| outputs=[gr.Textbox(label="Execution duration"), | |
| gr.Annotatedimage(label="Interactive Object Detection",color_map=color_map_dict), | |
| gr.DataFrame(label="Predicted Benthic Habitat",headers=["Prediction", "Confidence"]), | |
| gr.DataFrame(label="Habitat Confidence Values",headers=["Classification", "Confidence"]), | |
| gr.Image(label="Instance Segmentation Result"), | |
| gr.DataFrame(label="Identified Classes Confidence Values",headers=["Classification", "Confidence"])], | |
| description="Last updated: 8th May 2024", | |
| title= "AMBULANT Benthic Habitat Identification System", | |
| ) | |
| conf_matrix_img = gr.Image(latest_conf_matrix, label="Latest Model") | |
| labels_img = gr.Image(latest_labels, label="Latest Model") | |
| f = open('docs/changelog.html', 'r') | |
| changelog_data = f.read() | |
| f.close() | |
| changelog = gr.HTML(value=changelog_data) | |
| f = open('docs/bugreports.html', 'r') | |
| bugs_data = f.read() | |
| f.close() | |
| bugs = gr.HTML(value=bugs_data) | |
| ifacepro = gr.TabbedInterface(interface_list=[iface, conf_matrix_img,labels_img,changelog,bugs], tab_names=["Test Environment", "Normalised Confusion Matrix", "Total Class Instances", "Changelog", "Bug Reporting"]) | |
| ifacepro.launch(share=True) |