Spaces:
Sleeping
Sleeping
Restore meme outcome filters
Browse files
app.py
CHANGED
|
@@ -103,9 +103,9 @@ def _render(
|
|
| 103 |
|
| 104 |
|
| 105 |
def apply_filters(
|
| 106 |
-
search: str, model_id: str,
|
| 107 |
) -> tuple[Any, ...]:
|
| 108 |
-
ids = DATA.filtered_ids(search, model_id,
|
| 109 |
return (ids, *_render(ids, 0, hide_ground_truth, model_id))
|
| 110 |
|
| 111 |
|
|
@@ -255,15 +255,15 @@ def build_app() -> gr.Blocks:
|
|
| 255 |
min_width=210,
|
| 256 |
scale=2,
|
| 257 |
)
|
| 258 |
-
|
| 259 |
choices=[
|
| 260 |
-
("Any
|
| 261 |
-
("
|
| 262 |
-
("
|
| 263 |
-
("
|
| 264 |
],
|
| 265 |
value="all",
|
| 266 |
-
label="
|
| 267 |
show_label=False,
|
| 268 |
min_width=180,
|
| 269 |
scale=2,
|
|
@@ -307,12 +307,16 @@ def build_app() -> gr.Blocks:
|
|
| 307 |
predictions,
|
| 308 |
]
|
| 309 |
filter_outputs = [ids_state, *render_outputs]
|
| 310 |
-
filter_inputs = [search, model,
|
| 311 |
|
| 312 |
demo.load(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
|
| 313 |
search.submit(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
|
| 314 |
model.change(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
|
| 315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
previous.click(
|
| 317 |
lambda ids, idx, hidden, selected: step_item(
|
| 318 |
ids, idx, -1, hidden, selected
|
|
|
|
| 103 |
|
| 104 |
|
| 105 |
def apply_filters(
|
| 106 |
+
search: str, model_id: str, outcome: str, hide_ground_truth: bool
|
| 107 |
) -> tuple[Any, ...]:
|
| 108 |
+
ids = DATA.filtered_ids(search, model_id, outcome)
|
| 109 |
return (ids, *_render(ids, 0, hide_ground_truth, model_id))
|
| 110 |
|
| 111 |
|
|
|
|
| 255 |
min_width=210,
|
| 256 |
scale=2,
|
| 257 |
)
|
| 258 |
+
outcome = gr.Dropdown(
|
| 259 |
choices=[
|
| 260 |
+
("Any outcome", "all"),
|
| 261 |
+
("All got it right", "all_correct"),
|
| 262 |
+
("All got it wrong", "all_incorrect"),
|
| 263 |
+
("Mixed", "mixed"),
|
| 264 |
],
|
| 265 |
value="all",
|
| 266 |
+
label="Outcome",
|
| 267 |
show_label=False,
|
| 268 |
min_width=180,
|
| 269 |
scale=2,
|
|
|
|
| 307 |
predictions,
|
| 308 |
]
|
| 309 |
filter_outputs = [ids_state, *render_outputs]
|
| 310 |
+
filter_inputs = [search, model, outcome, hide_ground_truth]
|
| 311 |
|
| 312 |
demo.load(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
|
| 313 |
search.submit(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
|
| 314 |
model.change(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
|
| 315 |
+
outcome.change(
|
| 316 |
+
apply_filters,
|
| 317 |
+
inputs=filter_inputs,
|
| 318 |
+
outputs=filter_outputs,
|
| 319 |
+
)
|
| 320 |
previous.click(
|
| 321 |
lambda ids, idx, hidden, selected: step_item(
|
| 322 |
ids, idx, -1, hidden, selected
|
data.py
CHANGED
|
@@ -108,7 +108,7 @@ class BenchmarkData:
|
|
| 108 |
self,
|
| 109 |
search: str = "",
|
| 110 |
model_id: str = "all",
|
| 111 |
-
|
| 112 |
) -> list[str]:
|
| 113 |
needle = search.strip().casefold()
|
| 114 |
matches: list[str] = []
|
|
@@ -127,24 +127,16 @@ class BenchmarkData:
|
|
| 127 |
predictions = self.predictions(post_id, model_id)
|
| 128 |
if model_id != "all" and not predictions:
|
| 129 |
continue
|
| 130 |
-
|
| 131 |
-
row.get("consensus_verdict")
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
| 133 |
continue
|
| 134 |
-
if
|
| 135 |
-
row.get("consensus_verdict") == "incorrect" for row in predictions
|
| 136 |
-
):
|
| 137 |
continue
|
| 138 |
-
if
|
| 139 |
-
len(
|
| 140 |
-
{
|
| 141 |
-
judgment.get("verdict")
|
| 142 |
-
for judgment in self.judgments(int(row["prediction_id"]))
|
| 143 |
-
}
|
| 144 |
-
)
|
| 145 |
-
> 1
|
| 146 |
-
for row in predictions
|
| 147 |
-
):
|
| 148 |
continue
|
| 149 |
matches.append(post_id)
|
| 150 |
return matches
|
|
|
|
| 108 |
self,
|
| 109 |
search: str = "",
|
| 110 |
model_id: str = "all",
|
| 111 |
+
outcome: str = "all",
|
| 112 |
) -> list[str]:
|
| 113 |
needle = search.strip().casefold()
|
| 114 |
matches: list[str] = []
|
|
|
|
| 127 |
predictions = self.predictions(post_id, model_id)
|
| 128 |
if model_id != "all" and not predictions:
|
| 129 |
continue
|
| 130 |
+
verdicts = {
|
| 131 |
+
row.get("consensus_verdict")
|
| 132 |
+
for row in predictions
|
| 133 |
+
if row.get("consensus_verdict") in {"correct", "incorrect"}
|
| 134 |
+
}
|
| 135 |
+
if outcome == "all_correct" and verdicts != {"correct"}:
|
| 136 |
continue
|
| 137 |
+
if outcome == "all_incorrect" and verdicts != {"incorrect"}:
|
|
|
|
|
|
|
| 138 |
continue
|
| 139 |
+
if outcome == "mixed" and verdicts != {"correct", "incorrect"}:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
continue
|
| 141 |
matches.append(post_id)
|
| 142 |
return matches
|