{ "cells": [ { "cell_type": "code", "execution_count": 14, "id": "ae4232b9-fb9f-419a-9992-8481d1de6b61", "metadata": {}, "outputs": [], "source": [ "# |export\n", "import gradio as gr\n", "import pandas as pd\n", "from huggingface_hub import list_models" ] }, { "cell_type": "code", "execution_count": 107, "id": "51d7a652-f6d2-4cee-b787-88fc0fae0acd", "metadata": {}, "outputs": [], "source": [ "# |export\n", "def make_clickable_model(model_name, link=None):\n", " if link is None:\n", " link = \"https://huggingface.co/\" + model_name\n", " # Remove user from model name\n", " return f'{model_name.split(\"/\")[-1]}'\n", "\n", "\n", "def make_clickable_user(user_id):\n", " link = \"https://huggingface.co/\" + user_id\n", " return f'{user_id}'" ] }, { "cell_type": "code", "execution_count": 108, "id": "82d94a98-0e69-4400-9cb1-2e90ef6da519", "metadata": {}, "outputs": [], "source": [ "# |export\n", "def get_submissions(category):\n", " submissions = list_models(filter=[\"dreambooth-hackathon\", category], full=True)\n", " leaderboard_models = []\n", "\n", " for submission in submissions:\n", " # user, model, likes\n", " user_id = submission.id.split(\"/\")[0]\n", " leaderboard_models.append(\n", " (\n", " make_clickable_user(user_id),\n", " make_clickable_model(submission.id),\n", " submission.likes,\n", " )\n", " )\n", "\n", " df = pd.DataFrame(data=leaderboard_models, columns=[\"User\", \"Model\", \"Likes\"])\n", " df.sort_values(by=[\"Likes\"], ascending=False, inplace=True)\n", " df.insert(0, \"Rank\", list(range(1, len(df) + 1)))\n", " return df" ] }, { "cell_type": "code", "execution_count": 117, "id": "7579bfc6-ddf6-444d-ab7e-505734d86e4d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7894\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "