Spaces:
Sleeping
Sleeping
[Update]Add line 69-112
Browse files
app.py
CHANGED
@@ -66,76 +66,50 @@ raw_data = dummydf()
|
|
66 |
methods = list(set(raw_data['Method']))
|
67 |
metrics = ["Chruch","Parachute","Tench","Garbage Turch","Van Gogh","Violence","Illegal Activity","Nudity"]
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
#
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
# filtered_df = filtered_df.drop_duplicates(
|
114 |
-
# subset=[AutoEvalColumn.model.name, AutoEvalColumn.precision.name, AutoEvalColumn.revision.name]
|
115 |
-
# )
|
116 |
-
|
117 |
-
# return filtered_df
|
118 |
-
|
119 |
-
|
120 |
-
# def filter_models(
|
121 |
-
# df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, show_deleted: bool
|
122 |
-
# ) -> pd.DataFrame:
|
123 |
-
# # Show all models
|
124 |
-
# if show_deleted:
|
125 |
-
# filtered_df = df
|
126 |
-
# else: # Show only still on the hub models
|
127 |
-
# filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]
|
128 |
-
|
129 |
-
# type_emoji = [t[0] for t in type_query]
|
130 |
-
# filtered_df = filtered_df.loc[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
|
131 |
-
# filtered_df = filtered_df.loc[df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
|
132 |
-
|
133 |
-
# numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
|
134 |
-
# params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
|
135 |
-
# mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
|
136 |
-
# filtered_df = filtered_df.loc[mask]
|
137 |
-
|
138 |
-
# return filtered_df
|
139 |
|
140 |
|
141 |
demo = gr.Blocks(css=custom_css)
|
|
|
66 |
methods = list(set(raw_data['Method']))
|
67 |
metrics = ["Chruch","Parachute","Tench","Garbage Turch","Van Gogh","Violence","Illegal Activity","Nudity"]
|
68 |
|
69 |
+
def update_table(
|
70 |
+
hidden_df: pd.DataFrame,
|
71 |
+
columns_1: list,
|
72 |
+
columns_2: list,
|
73 |
+
columns_3: list,
|
74 |
+
model1: list,
|
75 |
+
):
|
76 |
+
|
77 |
+
filtered_df = select_columns(hidden_df, columns_1, columns_2, columns_3)
|
78 |
+
|
79 |
+
filtered_df = filter_model1(filtered_df, model1)
|
80 |
+
|
81 |
+
return filtered_df
|
82 |
+
|
83 |
+
|
84 |
+
def select_columns(df: pd.DataFrame, columns_1: list, columns_2: list, columns_3: list) -> pd.DataFrame:
|
85 |
+
always_here_cols = ["Method"]
|
86 |
+
|
87 |
+
# We use COLS to maintain sorting
|
88 |
+
all_columns = metrics
|
89 |
+
|
90 |
+
if (len(columns_1)+len(columns_2) + len(columns_3)) == 0:
|
91 |
+
filtered_df = df[
|
92 |
+
always_here_cols +
|
93 |
+
[c for c in all_columns if c in df.columns]
|
94 |
+
]
|
95 |
+
|
96 |
+
else:
|
97 |
+
filtered_df = df[
|
98 |
+
always_here_cols +
|
99 |
+
[c for c in all_columns if c in df.columns and (c in columns_1 or c in columns_2 or c in columns_3 ) ]
|
100 |
+
]
|
101 |
+
|
102 |
+
return filtered_df
|
103 |
+
|
104 |
+
|
105 |
+
def filter_model1(df: pd.DataFrame, model_query: list) -> pd.DataFrame:
|
106 |
+
# Show all models
|
107 |
+
if len(model_query) == 0:
|
108 |
+
return df
|
109 |
+
|
110 |
+
filtered_df = df
|
111 |
+
filtered_df = filtered_df[filtered_df["Method"].isin(model_query)]
|
112 |
+
return filtered_df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
|
115 |
demo = gr.Blocks(css=custom_css)
|