File size: 942 Bytes
f7ce1ca
 
 
 
 
 
38b1bd2
f7ce1ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38b1bd2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from pathlib import Path
import gradio as gr
from huggingface_hub import snapshot_download

snapshot_download("tiiuae/falcon-7b")

DATA_PATH = Path("./")

def get_storage():
    files = [
        {
            "orig_name": file.name,
            "name": file.resolve(),
            "size": file.stat().st_size,
            "data": None,
            "is_file": True,
        }
        for file in DATA_PATH.glob("**/*")
        if file.is_file()
    ]
    usage = sum([f['size'] for f in files])

    return files, f"{usage/(1024.0 ** 3):.3f}GB"


with gr.Blocks() as app:
    with gr.Row():
        with gr.Column():
            btn = gr.Button("Run")
        with gr.Column():
            files = gr.Files(label="Files")
            storage = gr.Text(label="Total Usage")
    btn.click(get_storage, inputs=None, outputs=[files, storage], postprocess=False)

# Files that you explicitly allow on allowed_paths
app.launch(allowed_paths=["./"])