Spaces:
Runtime error
Runtime error
ercanburak
commited on
Commit
•
89de2dd
1
Parent(s):
24aac30
display metric names left to first column
Browse files
app.py
CHANGED
@@ -113,6 +113,10 @@ layout_parts = []
|
|
113 |
video_paths = []
|
114 |
row_heights = [""]*num_rows
|
115 |
gt_viz_indices = []
|
|
|
|
|
|
|
|
|
116 |
for row_idx in range(num_rows):
|
117 |
for col_idx in range(num_cols):
|
118 |
vid_idx = len(video_paths)
|
@@ -120,36 +124,43 @@ for row_idx in range(num_rows):
|
|
120 |
if cur_model['name'] == "gt":
|
121 |
if row_idx < len(gt_viz):
|
122 |
video_path = get_path_for_viz(data_base_path, selected_dataset, selected_sequence, cur_model, gt_viz[row_idx])
|
123 |
-
|
124 |
-
|
125 |
gt_viz_indices.append(vid_idx)
|
126 |
else:
|
127 |
continue
|
128 |
else:
|
129 |
if row_idx < len(model_viz):
|
130 |
video_path = get_path_for_viz(data_base_path, selected_dataset, selected_sequence, cur_model, model_viz[row_idx])
|
131 |
-
|
132 |
-
|
133 |
else:
|
134 |
continue
|
135 |
|
136 |
if row_heights[row_idx] == "":
|
137 |
row_heights[row_idx] = "h{}".format(vid_idx)
|
138 |
if row_idx == 0:
|
139 |
-
# font_size
|
140 |
-
# pad=240:180+23:0:180:white
|
141 |
pad_height = font_size+padding*2
|
142 |
pad_txt_str = ",pad={}:{}:0:{}:white".format(w+padding*2, h+font_size+padding*4, pad_height)
|
143 |
text_str = get_text_str(pad_height, w, cur_model['display_name'], font_path, font_size)
|
144 |
pad_txt_str = pad_txt_str + "," + text_str
|
|
|
|
|
|
|
|
|
145 |
else:
|
146 |
pad_txt_str = ""
|
|
|
147 |
input_filter_part = "[{}:v]scale={}:-1,{}{}[v{}]".format(vid_idx, w, pad_str, pad_txt_str, vid_idx)
|
148 |
input_filter_parts.append(input_filter_part)
|
149 |
xstack_input_part = "[v{}]".format(vid_idx)
|
150 |
xstack_input_parts.append(xstack_input_part)
|
151 |
video_paths.append(video_path)
|
152 |
-
|
|
|
|
|
|
|
|
|
153 |
if cur_model['name'] == "gt":
|
154 |
layout_h = "+".join(["h{}".format(i) for i in gt_viz_indices[:-1]]) if row_idx > 0 else "0"
|
155 |
else:
|
|
|
113 |
video_paths = []
|
114 |
row_heights = [""]*num_rows
|
115 |
gt_viz_indices = []
|
116 |
+
if len(model_viz) > 1:
|
117 |
+
left_pad = font_size*max([len(viz['display_name']) for viz in model_viz[1:]]) + padding*2
|
118 |
+
else:
|
119 |
+
left_pad = 0
|
120 |
for row_idx in range(num_rows):
|
121 |
for col_idx in range(num_cols):
|
122 |
vid_idx = len(video_paths)
|
|
|
124 |
if cur_model['name'] == "gt":
|
125 |
if row_idx < len(gt_viz):
|
126 |
video_path = get_path_for_viz(data_base_path, selected_dataset, selected_sequence, cur_model, gt_viz[row_idx])
|
127 |
+
if not os.path.isfile(video_path):
|
128 |
+
raise ValueError("Video path does not exist: " + video_path)
|
129 |
gt_viz_indices.append(vid_idx)
|
130 |
else:
|
131 |
continue
|
132 |
else:
|
133 |
if row_idx < len(model_viz):
|
134 |
video_path = get_path_for_viz(data_base_path, selected_dataset, selected_sequence, cur_model, model_viz[row_idx])
|
135 |
+
if not os.path.isfile(video_path):
|
136 |
+
raise ValueError("Video path does not exist: " + video_path)
|
137 |
else:
|
138 |
continue
|
139 |
|
140 |
if row_heights[row_idx] == "":
|
141 |
row_heights[row_idx] = "h{}".format(vid_idx)
|
142 |
if row_idx == 0:
|
|
|
|
|
143 |
pad_height = font_size+padding*2
|
144 |
pad_txt_str = ",pad={}:{}:0:{}:white".format(w+padding*2, h+font_size+padding*4, pad_height)
|
145 |
text_str = get_text_str(pad_height, w, cur_model['display_name'], font_path, font_size)
|
146 |
pad_txt_str = pad_txt_str + "," + text_str
|
147 |
+
elif row_idx > 0 and col_idx == 0:
|
148 |
+
pad_txt_str = ",pad={}:ih:{}:0:white".format(w + left_pad + padding*2, left_pad)
|
149 |
+
text_str = get_text_str("h", left_pad, model_viz[row_idx]['display_name'], font_path, font_size)
|
150 |
+
pad_txt_str = pad_txt_str + "," + text_str
|
151 |
else:
|
152 |
pad_txt_str = ""
|
153 |
+
|
154 |
input_filter_part = "[{}:v]scale={}:-1,{}{}[v{}]".format(vid_idx, w, pad_str, pad_txt_str, vid_idx)
|
155 |
input_filter_parts.append(input_filter_part)
|
156 |
xstack_input_part = "[v{}]".format(vid_idx)
|
157 |
xstack_input_parts.append(xstack_input_part)
|
158 |
video_paths.append(video_path)
|
159 |
+
if row_idx == 0 or col_idx > 0:
|
160 |
+
layout_w_parts = [str(left_pad)] + ["w{}".format(i) for i in range(col_idx)]
|
161 |
+
layout_w = "+".join(layout_w_parts)
|
162 |
+
else:
|
163 |
+
layout_w = "+".join(["w{}".format(i) for i in range(col_idx)]) if col_idx > 0 else "0"
|
164 |
if cur_model['name'] == "gt":
|
165 |
layout_h = "+".join(["h{}".format(i) for i in gt_viz_indices[:-1]]) if row_idx > 0 else "0"
|
166 |
else:
|