Spaces:
Running
Running
Category filter (#3)
Browse files- Filter categories (2d04ce888baa749cea99eebb988103adba62a52a)
app.py
CHANGED
@@ -12,6 +12,9 @@ ds_results = load_dataset("visionLMsftw/vibe-testing-results", split="train")
|
|
12 |
models = get_model_names(ds_results)
|
13 |
responses = get_responses(ds_results)
|
14 |
|
|
|
|
|
|
|
15 |
|
16 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
17 |
gr.Markdown("# VLMVibeEval")
|
@@ -20,27 +23,48 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
20 |
|
21 |
with gr.Column(visible=True) as model_mode:
|
22 |
selected_model = gr.Dropdown(models, label="Choose model")
|
|
|
|
|
|
|
|
|
|
|
23 |
model_output = gr.HTML()
|
24 |
current_index = gr.State(value=0)
|
25 |
current_html = gr.State(value="")
|
26 |
|
27 |
-
def load_initial(model):
|
28 |
-
html = display_model_responses_html(evaluation_data, responses, model, 0)
|
29 |
return html, 5, html
|
30 |
-
|
31 |
-
def load_more(model, index, html_so_far):
|
32 |
-
new_html = display_model_responses_html(evaluation_data, responses, model, index)
|
33 |
updated_html = html_so_far + new_html
|
34 |
return updated_html, index + 5, updated_html
|
35 |
|
36 |
-
selected_model.change(
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
with gr.Column(visible=False) as example_mode:
|
46 |
category = gr.Dropdown(
|
@@ -83,14 +107,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
83 |
align-items: center;
|
84 |
justify-content: center;
|
85 |
}
|
86 |
-
|
87 |
#image-modal img {
|
88 |
max-width: 90%;
|
89 |
max-height: 90%;
|
90 |
border-radius: 8px;
|
91 |
box-shadow: 0 0 20px rgba(255,255,255,0.3);
|
92 |
}
|
93 |
-
|
94 |
#image-modal .close {
|
95 |
position: absolute;
|
96 |
top: 20px; right: 30px;
|
@@ -100,12 +122,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
100 |
font-weight: bold;
|
101 |
}
|
102 |
</style>
|
103 |
-
|
104 |
<div id="image-modal" onclick="closeModal(event)">
|
105 |
<span class="close" onclick="closeModal(event)">×</span>
|
106 |
<img id="modal-img" src="" alt="Enlarged Image" />
|
107 |
</div>
|
108 |
-
|
109 |
<script>
|
110 |
function openImage(src) {
|
111 |
const modal = document.getElementById('image-modal');
|
@@ -113,13 +133,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
113 |
img.src = src;
|
114 |
modal.style.display = 'flex';
|
115 |
}
|
116 |
-
|
117 |
function closeModal(event) {
|
118 |
if (event.target.id === 'image-modal' || event.target.classList.contains('close')) {
|
119 |
document.getElementById('image-modal').style.display = 'none';
|
120 |
}
|
121 |
}
|
122 |
-
|
123 |
// Optional: close on ESC key
|
124 |
document.addEventListener('keydown', function(e) {
|
125 |
if (e.key === "Escape") {
|
|
|
12 |
models = get_model_names(ds_results)
|
13 |
responses = get_responses(ds_results)
|
14 |
|
15 |
+
default_category = evaluation_data[0]["category"]
|
16 |
+
default_example_id = evaluation_data[0]["id"]
|
17 |
+
|
18 |
|
19 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
20 |
gr.Markdown("# VLMVibeEval")
|
|
|
23 |
|
24 |
with gr.Column(visible=True) as model_mode:
|
25 |
selected_model = gr.Dropdown(models, label="Choose model")
|
26 |
+
model_category = gr.Dropdown(
|
27 |
+
choices=list(set(ex["category"] for ex in evaluation_data)),
|
28 |
+
label="Category",
|
29 |
+
value=default_category
|
30 |
+
)
|
31 |
model_output = gr.HTML()
|
32 |
current_index = gr.State(value=0)
|
33 |
current_html = gr.State(value="")
|
34 |
|
35 |
+
def load_initial(model, category):
|
36 |
+
html = display_model_responses_html(evaluation_data, responses, model, start_index=0, batch_size=5, category=category)
|
37 |
return html, 5, html
|
38 |
+
|
39 |
+
def load_more(model, index, html_so_far, category):
|
40 |
+
new_html = display_model_responses_html(evaluation_data, responses, model, start_index=index, batch_size=5, category=category)
|
41 |
updated_html = html_so_far + new_html
|
42 |
return updated_html, index + 5, updated_html
|
43 |
|
44 |
+
selected_model.change(
|
45 |
+
load_initial,
|
46 |
+
inputs=[selected_model, model_category],
|
47 |
+
outputs=[model_output, current_index, current_html]
|
48 |
+
)
|
49 |
+
model_category.change(
|
50 |
+
load_initial,
|
51 |
+
inputs=[selected_model, model_category],
|
52 |
+
outputs=[model_output, current_index, current_html]
|
53 |
+
)
|
54 |
|
55 |
+
demo.load(
|
56 |
+
load_initial,
|
57 |
+
inputs=[selected_model, model_category],
|
58 |
+
outputs=[model_output, current_index, current_html]
|
59 |
+
)
|
60 |
|
61 |
+
|
62 |
+
more_button = gr.Button("Load more")
|
63 |
+
more_button.click(
|
64 |
+
load_more,
|
65 |
+
inputs=[selected_model, current_index, current_html, model_category],
|
66 |
+
outputs=[model_output, current_index, current_html]
|
67 |
+
)
|
68 |
|
69 |
with gr.Column(visible=False) as example_mode:
|
70 |
category = gr.Dropdown(
|
|
|
107 |
align-items: center;
|
108 |
justify-content: center;
|
109 |
}
|
|
|
110 |
#image-modal img {
|
111 |
max-width: 90%;
|
112 |
max-height: 90%;
|
113 |
border-radius: 8px;
|
114 |
box-shadow: 0 0 20px rgba(255,255,255,0.3);
|
115 |
}
|
|
|
116 |
#image-modal .close {
|
117 |
position: absolute;
|
118 |
top: 20px; right: 30px;
|
|
|
122 |
font-weight: bold;
|
123 |
}
|
124 |
</style>
|
|
|
125 |
<div id="image-modal" onclick="closeModal(event)">
|
126 |
<span class="close" onclick="closeModal(event)">×</span>
|
127 |
<img id="modal-img" src="" alt="Enlarged Image" />
|
128 |
</div>
|
|
|
129 |
<script>
|
130 |
function openImage(src) {
|
131 |
const modal = document.getElementById('image-modal');
|
|
|
133 |
img.src = src;
|
134 |
modal.style.display = 'flex';
|
135 |
}
|
|
|
136 |
function closeModal(event) {
|
137 |
if (event.target.id === 'image-modal' || event.target.classList.contains('close')) {
|
138 |
document.getElementById('image-modal').style.display = 'none';
|
139 |
}
|
140 |
}
|
|
|
141 |
// Optional: close on ESC key
|
142 |
document.addEventListener('keydown', function(e) {
|
143 |
if (e.key === "Escape") {
|
utils.py
CHANGED
@@ -12,10 +12,16 @@ def image_to_base64(image):
|
|
12 |
def get_examples_by_category(evaluation_data, category):
|
13 |
return [ex["id"] for ex in evaluation_data if ex["category"] == category]
|
14 |
|
15 |
-
def display_model_responses_html(evaluation_data, responses, model, start_index=0, batch_size=5):
|
16 |
start_time = time.time()
|
17 |
html = ""
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
image_thumbnail = ex["image_thumbnail"]
|
20 |
image_full_url = ex["image_full_url"]
|
21 |
img_id = ex["id"]
|
@@ -46,6 +52,7 @@ def display_model_responses_html(evaluation_data, responses, model, start_index=
|
|
46 |
|
47 |
return html
|
48 |
|
|
|
49 |
def display_example_responses_html(evaluation_data, responses, models, example_id):
|
50 |
ex = next(e for e in evaluation_data if e["id"] == example_id)
|
51 |
image_thumbnail = ex["image_thumbnail"]
|
|
|
12 |
def get_examples_by_category(evaluation_data, category):
|
13 |
return [ex["id"] for ex in evaluation_data if ex["category"] == category]
|
14 |
|
15 |
+
def display_model_responses_html(evaluation_data, responses, model, start_index=0, batch_size=5, category=None):
|
16 |
start_time = time.time()
|
17 |
html = ""
|
18 |
+
|
19 |
+
if category is not None:
|
20 |
+
filtered_data = [ex for ex in evaluation_data if ex["category"] == category]
|
21 |
+
else:
|
22 |
+
filtered_data = evaluation_data
|
23 |
+
|
24 |
+
for ex in filtered_data[start_index:start_index + batch_size]:
|
25 |
image_thumbnail = ex["image_thumbnail"]
|
26 |
image_full_url = ex["image_full_url"]
|
27 |
img_id = ex["id"]
|
|
|
52 |
|
53 |
return html
|
54 |
|
55 |
+
|
56 |
def display_example_responses_html(evaluation_data, responses, models, example_id):
|
57 |
ex = next(e for e in evaluation_data if e["id"] == example_id)
|
58 |
image_thumbnail = ex["image_thumbnail"]
|