(is_depth_tab)
| 25 | |
| 26 | |
| 27 | def main_ui_panel(is_depth_tab): |
| 28 | inp = GradioComponentBundle() |
| 29 | # TODO: Greater visual separation |
| 30 | with gr.Blocks(): |
| 31 | with gr.Row() as cur_option_root: |
| 32 | inp -= 'depthmap_gen_row_0', cur_option_root |
| 33 | inp += go.COMPUTE_DEVICE, gr.Radio(label="Compute on", choices=['GPU', 'CPU'], value='GPU') |
| 34 | # TODO: Should return value instead of index. Maybe Enum should be used? |
| 35 | inp += go.MODEL_TYPE, gr.Dropdown(label="Model", |
| 36 | choices=['res101', 'dpt_beit_large_512 (midas 3.1)', |
| 37 | 'dpt_beit_large_384 (midas 3.1)', 'dpt_large_384 (midas 3.0)', |
| 38 | 'dpt_hybrid_384 (midas 3.0)', |
| 39 | 'midas_v21', 'midas_v21_small', |
| 40 | 'zoedepth_n (indoor)', 'zoedepth_k (outdoor)', 'zoedepth_nk', |
| 41 | 'Marigold v1', 'Depth Anything', 'Depth Anything v2 Small', |
| 42 | 'Depth Anything v2 Base', 'Depth Anything v2 Large'], |
| 43 | value='Depth Anything v2 Base', type="index") |
| 44 | with gr.Box() as cur_option_root: |
| 45 | inp -= 'depthmap_gen_row_1', cur_option_root |
| 46 | with gr.Row(): |
| 47 | inp += go.BOOST, gr.Checkbox(label="BOOST", |
| 48 | info="Generate depth map parts in a mosaic fashion - very slow", |
| 49 | value=False) |
| 50 | inp += go.NET_SIZE_MATCH, gr.Checkbox(label="Match net size to input size", |
| 51 | info="Net size affects quality, performance and VRAM usage") |
| 52 | with gr.Row() as options_depend_on_match_size: |
| 53 | inp += go.NET_WIDTH, gr.Slider(minimum=64, maximum=2048, step=64, label='Net width') |
| 54 | inp += go.NET_HEIGHT, gr.Slider(minimum=64, maximum=2048, step=64, label='Net height') |
| 55 | with gr.Row(): |
| 56 | inp += go.TILING_MODE, gr.Checkbox( |
| 57 | label='Tiling mode', info='Reduces seams that appear if the depthmap is tiled into a grid' |
| 58 | ) |
| 59 | |
| 60 | with gr.Box() as cur_option_root: |
| 61 | inp -= 'depthmap_gen_row_2', cur_option_root |
| 62 | with gr.Row(): |
| 63 | with gr.Group(): # 50% of width |
| 64 | inp += "save_outputs", gr.Checkbox(label="Save Outputs", value=True) |
| 65 | with gr.Group(): # 50% of width |
| 66 | inp += go.DO_OUTPUT_DEPTH, gr.Checkbox(label="Output DepthMap") |
| 67 | inp += go.OUTPUT_DEPTH_INVERT, gr.Checkbox(label="Invert (black=near, white=far)") |
| 68 | with gr.Row() as options_depend_on_output_depth_1: |
| 69 | inp += go.OUTPUT_DEPTH_COMBINE, gr.Checkbox( |
| 70 | label="Combine input and depthmap into one image") |
| 71 | inp += go.OUTPUT_DEPTH_COMBINE_AXIS, gr.Radio( |
| 72 | label="Combine axis", choices=['Vertical', 'Horizontal'], type="value", visible=False) |
| 73 | |
| 74 | with gr.Box() as cur_option_root: |
| 75 | inp -= 'depthmap_gen_row_3', cur_option_root |
| 76 | with gr.Row(): |
| 77 | inp += go.CLIPDEPTH, gr.Checkbox(label="Clip and renormalize DepthMap") |
| 78 | inp += go.CLIPDEPTH_MODE,\ |
| 79 | gr.Dropdown(label="Mode", choices=['Range', 'Outliers'], type="value", visible=False) |
| 80 | with gr.Row(visible=False) as clip_options_row_1: |
| 81 | inp += go.CLIPDEPTH_FAR, gr.Slider(minimum=0, maximum=1, step=0.001, label='Far clip') |
| 82 | inp += go.CLIPDEPTH_NEAR, gr.Slider(minimum=0, maximum=1, step=0.001, label='Near clip') |
| 83 | |
| 84 | with gr.Box(): |
no test coverage detected