xinchen9 commited on
Commit
6b22787
1 Parent(s): 4672a33

[Update]Add filter models

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -104,6 +104,7 @@ def update_table(
104
  # filtered_df = filtered_df[filtered_df['Open?'].isin([map_open[o] for o in open_query])]
105
  filtered_df=select_columns(filtered_df,model1_column)
106
  filtered_df = filter_queries(query, filtered_df)
 
107
  # filtered_df = filtered_df[[map_columns[k] for k in columns]]
108
  # deduplication
109
  # df = df.drop_duplicates(subset=["Model"])
@@ -116,7 +117,7 @@ def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
116
  return df[(df['Unlearned_Methods'].str.contains(query, case=False))]
117
 
118
 
119
- def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
120
  final_df = []
121
  if query != "":
122
  queries = [q.strip() for q in query.split(";")]
@@ -131,6 +132,25 @@ def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
131
 
132
  return filtered_df
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  def select_columns(df: pd.DataFrame, columns_1: list) -> pd.DataFrame:
135
  always_here_cols = ['Unlearned_Methods','Source', 'Diffusion_Models']
136
 
 
104
  # filtered_df = filtered_df[filtered_df['Open?'].isin([map_open[o] for o in open_query])]
105
  filtered_df=select_columns(filtered_df,model1_column)
106
  filtered_df = filter_queries(query, filtered_df)
107
+ filtered_df = filter_queries_model(open_query, filtered_df)
108
  # filtered_df = filtered_df[[map_columns[k] for k in columns]]
109
  # deduplication
110
  # df = df.drop_duplicates(subset=["Model"])
 
117
  return df[(df['Unlearned_Methods'].str.contains(query, case=False))]
118
 
119
 
120
+ def filter_queries(query: list, filtered_df: pd.DataFrame) -> pd.DataFrame:
121
  final_df = []
122
  if query != "":
123
  queries = [q.strip() for q in query.split(";")]
 
132
 
133
  return filtered_df
134
 
135
+ def search_table_model(df: pd.DataFrame, query: str) -> pd.DataFrame:
136
+ return df[(df['Models'].str.contains(query, case=False))]
137
+
138
+
139
+ def filter_queries_model(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
140
+ final_df = []
141
+ # if query != "":
142
+ # queries = [q.strip() for q in query.split(";")]
143
+ for _q in query:
144
+ _q = _q.strip()
145
+ if _q != "":
146
+ temp_filtered_df = search_table_model(filtered_df, _q)
147
+ if len(temp_filtered_df) > 0:
148
+ final_df.append(temp_filtered_df)
149
+ if len(final_df) > 0:
150
+ filtered_df = pd.concat(final_df)
151
+
152
+ return filtered_df
153
+
154
  def select_columns(df: pd.DataFrame, columns_1: list) -> pd.DataFrame:
155
  always_here_cols = ['Unlearned_Methods','Source', 'Diffusion_Models']
156