File size: 2,967 Bytes
a2bc65a
fbb3995
a2bc65a
 
5657a6c
 
29e11ce
5923581
5657a6c
 
a2bc65a
 
 
 
 
 
 
 
17fa97d
 
 
 
 
 
 
 
 
 
 
 
 
 
29e11ce
 
 
 
fe5c71c
 
 
17fa97d
5657a6c
a2bc65a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import gradio as gr
from gradio_scripts.file_reader import File


models = {
    'master': 'models/v5m_896_300best.pt',
    'elwha': 'models/YsEE20.pt',
    'elwha_train': 'models/YsEKvE20.pt',
}

def Upload_Gradio(gradio_components):
    with gr.Tabs():

        # Tab - uploading aris files for inference
        with gr.Tab("Infer ARIS"):

            gr.HTML("<p align='center' style='font-size: large;font-style: italic;'>Submit an .aris file to analyze result.</p>")
            
            with gr.Accordion("Advanced Settings", open=False):
                settings = []
                settings.append(gr.Dropdown(label="Model", value="master", choices=list(models.keys())))

                gr.Markdown("Detection Parameters")
                with gr.Row():
                    settings.append(gr.Slider(0, 1, value=0.05, label="Confidence Threshold", info="Confidence cutoff for detection boxes"))
                    settings.append(gr.Slider(0, 1, value=0.2, label="NMS IoU", info="IoU threshold for non-max suppression"))

                gr.Markdown("Tracking Parameters")
                with gr.Row():
                    settings.append(gr.Slider(0, 100, value=16, label="Min Hits", info="Minimum number of frames a fish has to appear in to count"))
                    settings.append(gr.Slider(0, 100, value=14, label="Max Age", info="Max age of occlusion before track is split"))

                with gr.Row():
                    gr.Markdown("Associative Tracking")
                    settings.append(gr.Checkbox(value=False, label="Enabled"))

                gr.Markdown("Other")
                settings.append(gr.Slider(0, 3, value=0.3, label="Min Length", info="Minimum length of fish (meters) in order for it to count"))

                gradio_components['hyperparams'] = settings

            #Input field for aris submission
            gradio_components['input'] = File(file_types=[".aris", ".ddf"], type="binary", label="ARIS Input", file_count="multiple")

        # Tab - uploading old result files to review
        with gr.Tab("Open Result"):
            gr.HTML("""
                <p align='center' style='font-size: large;font-style: italic;'>Submit an old zip file of results to visualize.</p>
                <p align='center' style='font-size: large;font-style: italic;'>If you want to edit annotations, also submit an aris file.</p>
            """)

            # Input for .zip result file
            gradio_components['result_input'] = File(file_types=[".zip"], type="binary", label="Upload result file", file_count="multiple")
            
            # Optional input for aris file to help with annotation editing
            gradio_components['result_aris_input'] = File(file_types=[".aris", ".ddf"], type="binary", label="Upload aris file (optional)", file_count="multiple")
            
            # Button for initializing review
            gradio_components['preview_result_btn'] = gr.Button("View Result")