File size: 4,131 Bytes
a2bc65a
fbb3995
a2bc65a
 
5657a6c
 
29e11ce
35b862f
 
5657a6c
 
a2bc65a
 
 
 
 
 
 
 
058f18b
17fa97d
 
 
 
 
 
 
 
 
 
 
 
 
7e4e0ac
 
 
98624cb
 
7e4e0ac
 
 
 
 
29e11ce
fe5c71c
ddf2165
 
 
fe5c71c
17fa97d
5657a6c
058f18b
 
 
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
61
62
63
64
65
66
67
68
69
70
71
72
73
import gradio as gr
from gradio_scripts.file_reader import File


models = {
    'master': 'models/v5m_896_300best.pt',
    'elwha': 'models/YsEE20.pt',
    'elwha+kenai_val': 'models/YsEKvE20.pt',
    'elwha+kenai_train': 'models/YsEKtE20.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>")
            
            settings = []
            with gr.Accordion("Advanced Settings", open=False):
                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"))

                tracker = gr.Dropdown(["None", "Confidence Boost", "ByteTrack"], label="Associative Tracking", value="None")
                settings.append(tracker)
                with gr.Row(visible=False) as track_row:
                    settings.append(gr.Slider(0, 5, value=1, label="Boost Power", info=""))
                    settings.append(gr.Slider(0, 1, value=1, label="Boost Decay", info=""))
                    tracker.change(lambda x:  gr.update(visible=(x=="Confidence Boost")), tracker, track_row)
                with gr.Row(visible=False) as track_row:
                    settings.append(gr.Slider(0, 1, value=0.1, label="Low Conf Threshold", info=""))
                    settings.append(gr.Slider(0, 1, value=0.3, label="High Conf Threshold", info=""))
                    tracker.change(lambda x:  gr.update(visible=(x=="ByteTrack")), tracker, track_row)

                gr.Markdown("Other")
                with gr.Row():
                    settings.append(gr.Slider(0, 3, value=0.3, label="Min Length", info="Minimum length of fish (meters) in order for it to count"))
                    settings.append(gr.Slider(0, 5, value=1, label="Min Travel", info="Minimum travel distance of track (meters) in order for it to count"))

                gradio_components['hyperparams'] = settings

            with gr.Row():
                settings.append(gr.CheckboxGroup(["Annotated Video", "Manual Marking", "PDF"], label="Output formats", interactive=True, value=["Annotated Video", "Manual Marking"]))

            #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")