HugSib's picture
Update app/utils.py
ec7c43d verified
raw
history blame
1.23 kB
from data.model_handler import ModelHandler
def make_clickable_model(model_name, link=None):
if link is None:
desanitized_model_name = model_name.replace("_", "/")
if '/captioning' in desanitized_model_name:
desanitized_model_name = desanitized_model_name.replace('/captioning', '')
if '/ocr' in desanitized_model_name:
desanitized_model_name = desanitized_model_name.replace('/ocr', '')
link = "https://huggingface.co/" + desanitized_model_name
return f'<a target="_blank" style="text-decoration: underline" href="{link}">{model_name}</a>'
def add_rank_and_format(df):
df = df.reset_index()
df = df.rename(columns={"index": "Model"})
df = ModelHandler.add_rank(df)
df["Model"] = df["Model"].apply(make_clickable_model)
return df
def get_refresh_function():
def _refresh(metric):
model_handler = ModelHandler()
data_task_category = model_handler.get_vidore_data(metric)
df = add_rank_and_format(data_task_category)
return df
return _refresh
def filter_models(data, search_term):
if search_term:
data = data[data['Model'].str.contains(search_term, case=False, na=False)]
return data