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'{model_name}' 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