Spaces:
Running
Running
updated module import
Browse files- .gitignore +1 -0
- app.py +25 -4
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
*embeddings.pkl
|
app.py
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
import pandas as pd
|
2 |
import numpy as np
|
3 |
import os
|
4 |
-
from
|
5 |
-
import pickle
|
6 |
import gradio as gr
|
7 |
import altair as alt
|
8 |
alt.data_transformers.enable("vegafusion")
|
9 |
-
from dynabench.task_evaluator import *
|
10 |
|
11 |
-
BASE_DIR = "
|
12 |
MODELS = ['qwenvl-chat', 'qwenvl', 'llava15-7b', 'llava15-13b', 'instructblip-vicuna13b', 'instructblip-vicuna7b']
|
13 |
VIDEO_MODELS = ['video-chat2-7b','video-llama2-7b','video-llama2-13b','chat-univi-7b','chat-univi-13b','video-llava-7b','video-chatgpt-7b']
|
14 |
domains = ["imageqa-2d-sticker", "imageqa-3d-tabletop", "imageqa-scene-graph", "videoqa-3d-tabletop", "videoqa-scene-graph"]
|
@@ -19,6 +18,28 @@ domain2folder = {"imageqa-2d-sticker": "2d",
|
|
19 |
"videoqa-scene-graph": "video-sg",
|
20 |
None: '2d'}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
def update_partition_and_models(domain):
|
23 |
domain = domain2folder[domain]
|
24 |
path = f"{BASE_DIR}/{domain}"
|
|
|
1 |
import pandas as pd
|
2 |
import numpy as np
|
3 |
import os
|
4 |
+
from prefixspan import PrefixSpan
|
|
|
5 |
import gradio as gr
|
6 |
import altair as alt
|
7 |
alt.data_transformers.enable("vegafusion")
|
8 |
+
# from dynabench.task_evaluator import *
|
9 |
|
10 |
+
BASE_DIR = "db"
|
11 |
MODELS = ['qwenvl-chat', 'qwenvl', 'llava15-7b', 'llava15-13b', 'instructblip-vicuna13b', 'instructblip-vicuna7b']
|
12 |
VIDEO_MODELS = ['video-chat2-7b','video-llama2-7b','video-llama2-13b','chat-univi-7b','chat-univi-13b','video-llava-7b','video-chatgpt-7b']
|
13 |
domains = ["imageqa-2d-sticker", "imageqa-3d-tabletop", "imageqa-scene-graph", "videoqa-3d-tabletop", "videoqa-scene-graph"]
|
|
|
18 |
"videoqa-scene-graph": "video-sg",
|
19 |
None: '2d'}
|
20 |
|
21 |
+
def find_frequent_patterns(k, df, scores=None):
|
22 |
+
if len(df) == 0:
|
23 |
+
return []
|
24 |
+
|
25 |
+
df = df.reset_index(drop=True)
|
26 |
+
cols = df.columns.to_list()
|
27 |
+
df = df.fillna('').astype('str')
|
28 |
+
db = [[(c, v) for c, v in zip(cols, d) if v] for d in df.values.tolist()]
|
29 |
+
|
30 |
+
ps = PrefixSpan(db)
|
31 |
+
patterns = ps.topk(k, closed=True)
|
32 |
+
if scores is None:
|
33 |
+
return patterns
|
34 |
+
else:
|
35 |
+
aggregated_scores = []
|
36 |
+
scores = np.asarray(scores)
|
37 |
+
for count, pattern in patterns:
|
38 |
+
q = ' and '.join([f"`{k}` == {repr(v)}" for k, v in pattern])
|
39 |
+
indices = df.query(q).index.to_numpy()
|
40 |
+
aggregated_scores.append(np.mean(scores[indices]))
|
41 |
+
return patterns, aggregated_scores
|
42 |
+
|
43 |
def update_partition_and_models(domain):
|
44 |
domain = domain2folder[domain]
|
45 |
path = f"{BASE_DIR}/{domain}"
|