Commit ·
f7ce1ca
1
Parent(s): b4ebf37
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from huggingface_hub import snapshot_download
|
| 4 |
+
|
| 5 |
+
snapshot_download("tiiuae/falcon-7b")
|
| 6 |
+
|
| 7 |
+
DATA_PATH = Path("/data")
|
| 8 |
+
|
| 9 |
+
def get_storage():
|
| 10 |
+
files = [
|
| 11 |
+
{
|
| 12 |
+
"orig_name": file.name,
|
| 13 |
+
"name": file.resolve(),
|
| 14 |
+
"size": file.stat().st_size,
|
| 15 |
+
"data": None,
|
| 16 |
+
"is_file": True,
|
| 17 |
+
}
|
| 18 |
+
for file in DATA_PATH.glob("**/*")
|
| 19 |
+
if file.is_file()
|
| 20 |
+
]
|
| 21 |
+
usage = sum([f['size'] for f in files])
|
| 22 |
+
|
| 23 |
+
return files, f"{usage/(1024.0 ** 3):.3f}GB"
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
with gr.Blocks() as app:
|
| 27 |
+
with gr.Row():
|
| 28 |
+
with gr.Column():
|
| 29 |
+
btn = gr.Button("Run")
|
| 30 |
+
with gr.Column():
|
| 31 |
+
files = gr.Files(label="Files")
|
| 32 |
+
storage = gr.Text(label="Total Usage")
|
| 33 |
+
btn.click(get_storage, inputs=None, outputs=[files, storage], postprocess=False)
|
| 34 |
+
|
| 35 |
+
# Files that you explicitly allow on allowed_paths
|
| 36 |
+
app.launch(allowed_paths=["/data"])
|