{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "f598db56-5a32-42b5-98de-790a3acdbd62", "metadata": {}, "outputs": [], "source": [ "#|export\n", "import gradio as gr\n", "from fastcore.net import urljson, HTTPError" ] }, { "cell_type": "code", "execution_count": 3, "id": "62cf74c6-a8cb-4c62-99c5-ad1c1776aed1", "metadata": {}, "outputs": [], "source": [ "#|export\n", "def size(repo:str):\n", " \"Returns the size in GB of a HuggingFace Dataset.\"\n", " url = f'https://huggingface.co/api/datasets/{repo}'\n", " try: resp = urljson(f'{url}/treesize/main')\n", " except HTTPError: return f'Did not find repo: {url}'\n", " gb = resp['size'] / 1e9\n", " return f'{gb:.2f} GB'" ] }, { "cell_type": "code", "execution_count": 4, "id": "568dafe6-9edf-4b6b-934c-62e7d26629bf", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'5.49 GB'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "size(\"tglcourse/CelebA-faces-cropped-128\")" ] }, { "cell_type": "code", "execution_count": 5, "id": "8bcb5f89-4a46-4615-aedf-34dff061d0df", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7860\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "