3
3
import os
4
4
from collections import defaultdict
5
5
from pathlib import Path
6
- from typing import Dict , List , Tuple
6
+ from typing import Tuple
7
7
8
8
import pandas as pd
9
9
import streamlit as st
16
16
17
17
18
18
@st .cache_resource
19
- def update_labeled_file_list (model_preds_folders : List [str ], use_ood : bool = False ) -> List [list ]:
19
+ def update_labeled_file_list (model_preds_folders : list [str ], use_ood : bool = False ) -> list [list ]:
20
20
per_model_preds = []
21
21
for model_pred_folder in model_preds_folders :
22
22
# pull labeled results from each model folder
@@ -42,9 +42,9 @@ def update_labeled_file_list(model_preds_folders: List[str], use_ood: bool = Fal
42
42
@st .cache_resource
43
43
def update_vid_metric_files_list (
44
44
video : str ,
45
- model_preds_folders : List [str ],
45
+ model_preds_folders : list [str ],
46
46
video_subdir : str = "video_preds" ,
47
- ) -> List [list ]:
47
+ ) -> list [list ]:
48
48
per_vid_preds = []
49
49
for model_preds_folder in model_preds_folders :
50
50
# pull each prediction file associated with a particular video
@@ -65,7 +65,7 @@ def update_vid_metric_files_list(
65
65
66
66
67
67
@st .cache_resource
68
- def get_all_videos (model_preds_folders : List [str ], video_subdir : str = "video_preds" ) -> list :
68
+ def get_all_videos (model_preds_folders : list [str ], video_subdir : str = "video_preds" ) -> list :
69
69
# find each video that is predicted on by the models
70
70
# wrap in Path so that it looks like an UploadedFile object
71
71
# returned by streamlit's file_uploader
@@ -89,7 +89,7 @@ def get_all_videos(model_preds_folders: List[str], video_subdir: str = "video_pr
89
89
90
90
91
91
@st .cache_data
92
- def concat_dfs (dframes : Dict [str , pd .DataFrame ]) -> Tuple [pd .DataFrame , List [str ]]:
92
+ def concat_dfs (dframes : dict [str , pd .DataFrame ]) -> Tuple [pd .DataFrame , list [str ]]:
93
93
counter = 0
94
94
for model_name , dframe in dframes .items ():
95
95
mask = dframe .columns .get_level_values ("coords" ).isin (["x" , "y" , "likelihood" ])
@@ -143,7 +143,7 @@ def get_df_scatter(
143
143
return pd .concat (df_scatters )
144
144
145
145
146
- def get_col_names (keypoint : str , coordinate : str , models : List [str ]) -> List [str ]:
146
+ def get_col_names (keypoint : str , coordinate : str , models : list [str ]) -> list [str ]:
147
147
return [get_full_name (keypoint , coordinate , model ) for model in models ]
148
148
149
149
@@ -162,7 +162,7 @@ def get_full_name(keypoint: str, coordinate: str, model: str) -> str:
162
162
# ----------------------------------------------
163
163
@st .cache_data
164
164
def build_precomputed_metrics_df (
165
- dframes : Dict [str , pd .DataFrame ], keypoint_names : List [str ], ** kwargs ,
165
+ dframes : dict [str , pd .DataFrame ], keypoint_names : list [str ], ** kwargs ,
166
166
) -> dict :
167
167
concat_dfs = defaultdict (list )
168
168
for model_name , df_dict in dframes .items ():
@@ -194,7 +194,7 @@ def build_precomputed_metrics_df(
194
194
195
195
@st .cache_data
196
196
def get_precomputed_error (
197
- df : pd .DataFrame , keypoint_names : List [str ], model_name : str ,
197
+ df : pd .DataFrame , keypoint_names : list [str ], model_name : str ,
198
198
) -> pd .DataFrame :
199
199
# collect results
200
200
df_ = df
@@ -206,7 +206,7 @@ def get_precomputed_error(
206
206
207
207
@st .cache_data
208
208
def compute_confidence (
209
- df : pd .DataFrame , keypoint_names : List [str ], model_name : str , ** kwargs ,
209
+ df : pd .DataFrame , keypoint_names : list [str ], model_name : str , ** kwargs ,
210
210
) -> pd .DataFrame :
211
211
212
212
if df .shape [1 ] % 3 == 1 :
@@ -236,7 +236,7 @@ def get_model_folders(
236
236
model_dir : str ,
237
237
require_predictions : bool = True ,
238
238
require_tb_logs : bool = False ,
239
- ) -> List [str ]:
239
+ ) -> list [str ]:
240
240
"""Find all model folders in a higher-level directory, conditional on directory contents."""
241
241
# strip trailing slash if present
242
242
if model_dir [- 1 ] == os .sep :
@@ -260,7 +260,7 @@ def get_model_folders(
260
260
261
261
262
262
# just to get the last two levels of the path
263
- def get_model_folders_vis (model_folders : List [str ]) -> List [str ]:
263
+ def get_model_folders_vis (model_folders : list [str ]) -> list [str ]:
264
264
fs = []
265
265
for f in model_folders :
266
266
fs .append (f .split ("/" )[- 2 :])
0 commit comments