Spaces:
Sleeping
Sleeping
Commit
•
9091ba2
1
Parent(s):
c4e0057
first commit
Browse files- .ipynb_checkpoints/app-checkpoint.ipynb +174 -0
- app.ipynb +174 -0
- app.py +21 -0
- requirements.txt +1 -0
.ipynb_checkpoints/app-checkpoint.ipynb
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
+
"id": "f598db56-5a32-42b5-98de-790a3acdbd62",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"#|export\n",
|
11 |
+
"import gradio as gr\n",
|
12 |
+
"from fastcore.net import urljson, HTTPError"
|
13 |
+
]
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"cell_type": "code",
|
17 |
+
"execution_count": 3,
|
18 |
+
"id": "62cf74c6-a8cb-4c62-99c5-ad1c1776aed1",
|
19 |
+
"metadata": {},
|
20 |
+
"outputs": [],
|
21 |
+
"source": [
|
22 |
+
"#|export\n",
|
23 |
+
"def size(repo:str):\n",
|
24 |
+
" \"Returns the size in GB of a HuggingFace Dataset.\"\n",
|
25 |
+
" url = f'https://huggingface.co/api/datasets/{repo}'\n",
|
26 |
+
" try: resp = urljson(f'{url}/treesize/main')\n",
|
27 |
+
" except HTTPError: return f'Did not find repo: {url}'\n",
|
28 |
+
" gb = resp['size'] / 1e9\n",
|
29 |
+
" return f'{gb:.2f} GB'"
|
30 |
+
]
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"cell_type": "code",
|
34 |
+
"execution_count": 4,
|
35 |
+
"id": "568dafe6-9edf-4b6b-934c-62e7d26629bf",
|
36 |
+
"metadata": {},
|
37 |
+
"outputs": [
|
38 |
+
{
|
39 |
+
"data": {
|
40 |
+
"text/plain": [
|
41 |
+
"'5.49 GB'"
|
42 |
+
]
|
43 |
+
},
|
44 |
+
"execution_count": 4,
|
45 |
+
"metadata": {},
|
46 |
+
"output_type": "execute_result"
|
47 |
+
}
|
48 |
+
],
|
49 |
+
"source": [
|
50 |
+
"size(\"tglcourse/CelebA-faces-cropped-128\")"
|
51 |
+
]
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"cell_type": "code",
|
55 |
+
"execution_count": 5,
|
56 |
+
"id": "8bcb5f89-4a46-4615-aedf-34dff061d0df",
|
57 |
+
"metadata": {},
|
58 |
+
"outputs": [
|
59 |
+
{
|
60 |
+
"name": "stdout",
|
61 |
+
"output_type": "stream",
|
62 |
+
"text": [
|
63 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
64 |
+
"\n",
|
65 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
66 |
+
]
|
67 |
+
},
|
68 |
+
{
|
69 |
+
"data": {
|
70 |
+
"text/html": [
|
71 |
+
"<div><iframe src=\"http://127.0.0.1:7860/\" width=\"500\" height=\"450\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
72 |
+
],
|
73 |
+
"text/plain": [
|
74 |
+
"<IPython.core.display.HTML object>"
|
75 |
+
]
|
76 |
+
},
|
77 |
+
"metadata": {},
|
78 |
+
"output_type": "display_data"
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"data": {
|
82 |
+
"text/plain": []
|
83 |
+
},
|
84 |
+
"execution_count": 5,
|
85 |
+
"metadata": {},
|
86 |
+
"output_type": "execute_result"
|
87 |
+
}
|
88 |
+
],
|
89 |
+
"source": [
|
90 |
+
"#|export\n",
|
91 |
+
"iface = gr.Interface(fn=size, inputs=gr.Text(value=\"tglcourse/CelebA-faces-cropped-128\"), outputs=\"text\")\n",
|
92 |
+
"iface.launch(height=450, width=500)"
|
93 |
+
]
|
94 |
+
},
|
95 |
+
{
|
96 |
+
"cell_type": "code",
|
97 |
+
"execution_count": 6,
|
98 |
+
"id": "04e0bd54-851e-4821-bca7-3da3e43cc525",
|
99 |
+
"metadata": {},
|
100 |
+
"outputs": [
|
101 |
+
{
|
102 |
+
"name": "stdout",
|
103 |
+
"output_type": "stream",
|
104 |
+
"text": [
|
105 |
+
"Closing server running on port: 7860\n"
|
106 |
+
]
|
107 |
+
}
|
108 |
+
],
|
109 |
+
"source": [
|
110 |
+
"# this is only necessary in a notebook\n",
|
111 |
+
"iface.close()"
|
112 |
+
]
|
113 |
+
},
|
114 |
+
{
|
115 |
+
"cell_type": "code",
|
116 |
+
"execution_count": 7,
|
117 |
+
"id": "2701c26b-7c82-4f57-bf91-ab842b494ddb",
|
118 |
+
"metadata": {},
|
119 |
+
"outputs": [],
|
120 |
+
"source": [
|
121 |
+
"from nbdev.export import nb_export\n",
|
122 |
+
"nb_export('app.ipynb', lib_path='.', name='app')"
|
123 |
+
]
|
124 |
+
},
|
125 |
+
{
|
126 |
+
"cell_type": "code",
|
127 |
+
"execution_count": 8,
|
128 |
+
"id": "5bcd9468-574c-4839-962e-22571c3d1a53",
|
129 |
+
"metadata": {},
|
130 |
+
"outputs": [
|
131 |
+
{
|
132 |
+
"name": "stdout",
|
133 |
+
"output_type": "stream",
|
134 |
+
"text": [
|
135 |
+
"Writing requirements.txt\n"
|
136 |
+
]
|
137 |
+
}
|
138 |
+
],
|
139 |
+
"source": [
|
140 |
+
"%%writefile requirements.txt\n",
|
141 |
+
"fastcore"
|
142 |
+
]
|
143 |
+
},
|
144 |
+
{
|
145 |
+
"cell_type": "code",
|
146 |
+
"execution_count": null,
|
147 |
+
"id": "d8677e10-4b72-43de-ba48-debd881d238d",
|
148 |
+
"metadata": {},
|
149 |
+
"outputs": [],
|
150 |
+
"source": []
|
151 |
+
}
|
152 |
+
],
|
153 |
+
"metadata": {
|
154 |
+
"kernelspec": {
|
155 |
+
"display_name": "Python 3 (ipykernel)",
|
156 |
+
"language": "python",
|
157 |
+
"name": "python3"
|
158 |
+
},
|
159 |
+
"language_info": {
|
160 |
+
"codemirror_mode": {
|
161 |
+
"name": "ipython",
|
162 |
+
"version": 3
|
163 |
+
},
|
164 |
+
"file_extension": ".py",
|
165 |
+
"mimetype": "text/x-python",
|
166 |
+
"name": "python",
|
167 |
+
"nbconvert_exporter": "python",
|
168 |
+
"pygments_lexer": "ipython3",
|
169 |
+
"version": "3.12.3"
|
170 |
+
}
|
171 |
+
},
|
172 |
+
"nbformat": 4,
|
173 |
+
"nbformat_minor": 5
|
174 |
+
}
|
app.ipynb
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
+
"id": "f598db56-5a32-42b5-98de-790a3acdbd62",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"#|export\n",
|
11 |
+
"import gradio as gr\n",
|
12 |
+
"from fastcore.net import urljson, HTTPError"
|
13 |
+
]
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"cell_type": "code",
|
17 |
+
"execution_count": 3,
|
18 |
+
"id": "62cf74c6-a8cb-4c62-99c5-ad1c1776aed1",
|
19 |
+
"metadata": {},
|
20 |
+
"outputs": [],
|
21 |
+
"source": [
|
22 |
+
"#|export\n",
|
23 |
+
"def size(repo:str):\n",
|
24 |
+
" \"Returns the size in GB of a HuggingFace Dataset.\"\n",
|
25 |
+
" url = f'https://huggingface.co/api/datasets/{repo}'\n",
|
26 |
+
" try: resp = urljson(f'{url}/treesize/main')\n",
|
27 |
+
" except HTTPError: return f'Did not find repo: {url}'\n",
|
28 |
+
" gb = resp['size'] / 1e9\n",
|
29 |
+
" return f'{gb:.2f} GB'"
|
30 |
+
]
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"cell_type": "code",
|
34 |
+
"execution_count": 4,
|
35 |
+
"id": "568dafe6-9edf-4b6b-934c-62e7d26629bf",
|
36 |
+
"metadata": {},
|
37 |
+
"outputs": [
|
38 |
+
{
|
39 |
+
"data": {
|
40 |
+
"text/plain": [
|
41 |
+
"'5.49 GB'"
|
42 |
+
]
|
43 |
+
},
|
44 |
+
"execution_count": 4,
|
45 |
+
"metadata": {},
|
46 |
+
"output_type": "execute_result"
|
47 |
+
}
|
48 |
+
],
|
49 |
+
"source": [
|
50 |
+
"size(\"tglcourse/CelebA-faces-cropped-128\")"
|
51 |
+
]
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"cell_type": "code",
|
55 |
+
"execution_count": 5,
|
56 |
+
"id": "8bcb5f89-4a46-4615-aedf-34dff061d0df",
|
57 |
+
"metadata": {},
|
58 |
+
"outputs": [
|
59 |
+
{
|
60 |
+
"name": "stdout",
|
61 |
+
"output_type": "stream",
|
62 |
+
"text": [
|
63 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
64 |
+
"\n",
|
65 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
66 |
+
]
|
67 |
+
},
|
68 |
+
{
|
69 |
+
"data": {
|
70 |
+
"text/html": [
|
71 |
+
"<div><iframe src=\"http://127.0.0.1:7860/\" width=\"500\" height=\"450\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
72 |
+
],
|
73 |
+
"text/plain": [
|
74 |
+
"<IPython.core.display.HTML object>"
|
75 |
+
]
|
76 |
+
},
|
77 |
+
"metadata": {},
|
78 |
+
"output_type": "display_data"
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"data": {
|
82 |
+
"text/plain": []
|
83 |
+
},
|
84 |
+
"execution_count": 5,
|
85 |
+
"metadata": {},
|
86 |
+
"output_type": "execute_result"
|
87 |
+
}
|
88 |
+
],
|
89 |
+
"source": [
|
90 |
+
"#|export\n",
|
91 |
+
"iface = gr.Interface(fn=size, inputs=gr.Text(value=\"tglcourse/CelebA-faces-cropped-128\"), outputs=\"text\")\n",
|
92 |
+
"iface.launch(height=450, width=500)"
|
93 |
+
]
|
94 |
+
},
|
95 |
+
{
|
96 |
+
"cell_type": "code",
|
97 |
+
"execution_count": 6,
|
98 |
+
"id": "04e0bd54-851e-4821-bca7-3da3e43cc525",
|
99 |
+
"metadata": {},
|
100 |
+
"outputs": [
|
101 |
+
{
|
102 |
+
"name": "stdout",
|
103 |
+
"output_type": "stream",
|
104 |
+
"text": [
|
105 |
+
"Closing server running on port: 7860\n"
|
106 |
+
]
|
107 |
+
}
|
108 |
+
],
|
109 |
+
"source": [
|
110 |
+
"# this is only necessary in a notebook\n",
|
111 |
+
"iface.close()"
|
112 |
+
]
|
113 |
+
},
|
114 |
+
{
|
115 |
+
"cell_type": "code",
|
116 |
+
"execution_count": 7,
|
117 |
+
"id": "2701c26b-7c82-4f57-bf91-ab842b494ddb",
|
118 |
+
"metadata": {},
|
119 |
+
"outputs": [],
|
120 |
+
"source": [
|
121 |
+
"from nbdev.export import nb_export\n",
|
122 |
+
"nb_export('app.ipynb', lib_path='.', name='app')"
|
123 |
+
]
|
124 |
+
},
|
125 |
+
{
|
126 |
+
"cell_type": "code",
|
127 |
+
"execution_count": 8,
|
128 |
+
"id": "5bcd9468-574c-4839-962e-22571c3d1a53",
|
129 |
+
"metadata": {},
|
130 |
+
"outputs": [
|
131 |
+
{
|
132 |
+
"name": "stdout",
|
133 |
+
"output_type": "stream",
|
134 |
+
"text": [
|
135 |
+
"Writing requirements.txt\n"
|
136 |
+
]
|
137 |
+
}
|
138 |
+
],
|
139 |
+
"source": [
|
140 |
+
"%%writefile requirements.txt\n",
|
141 |
+
"fastcore"
|
142 |
+
]
|
143 |
+
},
|
144 |
+
{
|
145 |
+
"cell_type": "code",
|
146 |
+
"execution_count": null,
|
147 |
+
"id": "d8677e10-4b72-43de-ba48-debd881d238d",
|
148 |
+
"metadata": {},
|
149 |
+
"outputs": [],
|
150 |
+
"source": []
|
151 |
+
}
|
152 |
+
],
|
153 |
+
"metadata": {
|
154 |
+
"kernelspec": {
|
155 |
+
"display_name": "Python 3 (ipykernel)",
|
156 |
+
"language": "python",
|
157 |
+
"name": "python3"
|
158 |
+
},
|
159 |
+
"language_info": {
|
160 |
+
"codemirror_mode": {
|
161 |
+
"name": "ipython",
|
162 |
+
"version": 3
|
163 |
+
},
|
164 |
+
"file_extension": ".py",
|
165 |
+
"mimetype": "text/x-python",
|
166 |
+
"name": "python",
|
167 |
+
"nbconvert_exporter": "python",
|
168 |
+
"pygments_lexer": "ipython3",
|
169 |
+
"version": "3.12.3"
|
170 |
+
}
|
171 |
+
},
|
172 |
+
"nbformat": 4,
|
173 |
+
"nbformat_minor": 5
|
174 |
+
}
|
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['iface', 'size']
|
5 |
+
|
6 |
+
# %% app.ipynb 0
|
7 |
+
import gradio as gr
|
8 |
+
from fastcore.net import urljson, HTTPError
|
9 |
+
|
10 |
+
# %% app.ipynb 1
|
11 |
+
def size(repo:str):
|
12 |
+
"Returns the size in GB of a HuggingFace Dataset."
|
13 |
+
url = f'https://huggingface.co/api/datasets/{repo}'
|
14 |
+
try: resp = urljson(f'{url}/treesize/main')
|
15 |
+
except HTTPError: return f'Did not find repo: {url}'
|
16 |
+
gb = resp['size'] / 1e9
|
17 |
+
return f'{gb:.2f} GB'
|
18 |
+
|
19 |
+
# %% app.ipynb 3
|
20 |
+
iface = gr.Interface(fn=size, inputs=gr.Text(value="tglcourse/CelebA-faces-cropped-128"), outputs="text")
|
21 |
+
iface.launch(height=450, width=500)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastcore
|