cdactvm commited on
Commit
7e5a3b1
1 Parent(s): 446ddfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -25
app.py CHANGED
@@ -1,29 +1,30 @@
1
- import os
2
  import gradio as gr
 
3
 
4
- HF_TOKEN = os.getenv('HW_TOKEN')
5
- #print (HF_TOKEN)
6
- hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "save_audio")
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- def calculator(num1, operation, num2):
9
- if operation == "add":
10
- return num1 + num2
11
- elif operation == "subtract":
12
- return num1 - num2
13
- elif operation == "multiply":
14
- return num1 * num2
15
- elif operation == "divide":
16
- return num1 / num2
17
 
18
-
19
- iface = gr.Interface(
20
- calculator,
21
- ["number", gr.Radio(["add", "subtract", "multiply", "divide"]), "number"],
22
- "number",
23
- #description="Check out the crowd-sourced dataset at: [https://huggingface.co/datasets/aliabd/crowdsourced-calculator-demo](https://huggingface.co/datasets/aliabd/crowdsourced-calculator-demo)",
24
- allow_flagging="manual",
25
- flagging_options=["wrong sign", "off by one", "other"],
26
- flagging_callback=hf_writer
27
- )
28
-
29
- iface.launch()
 
 
1
  import gradio as gr
2
+ from pathlib import Path
3
 
4
+ DATA_PATH = Path("./") # Path("/data")
5
+ def get_storage():
6
+ files = [
7
+ {
8
+ "orig_name": file.name,
9
+ "name": file.resolve(),
10
+ "size": file.stat().st_size,
11
+ "data": None,
12
+ "is_file": True,
13
+ }
14
+ for file in DATA_PATH.glob("**/*")
15
+ if file.is_file()
16
+ ]
17
+ usage = sum([f['size'] for f in files])
18
+ return files, f"{usage/(1024.0 ** 3):.3f}GB"
19
 
20
+ with gr.Blocks() as app:
21
+ with gr.Row():
22
+ with gr.Column():
23
+ btn = gr.Button("Run")
24
+ with gr.Column():
25
+ files = gr.Files(label="Files")
26
+ storage = gr.Text(label="Total Usage")
27
+ btn.click(get_storage, inputs=None, outputs=[files, storage], postprocess=False)
 
28
 
29
+ # Files that you explicitly allow on allowed_paths
30
+ app.launch(allowed_paths=[str(DATA_PATH)])